Simple backup script
Super very and small backup script to use. You can use it to backup to your website or custom directories to a remote system. Make sure you have mounted one of your backup solutions.
# In this case I use a NAS (SMB) for backups, I normally have it premounted, but if you don't, mount first
$ sudo mount -t cifs //<IP address>/mount /mnt/point -o username=username,password=password,version=<1,2,3>
# Or an external disk
$ sudo mount /dev/sd(X) /mnt/point
Backup to:
– External backup drive
– SMB share
– GDrive
– Dropbox
– Etc
#!/bin/bash
# Set backup path (remote host)
$ bkp="/path/to/backups/filename"
# Set backup source
$ site="/path/to/source/"
# Set archive name inc date, %F = full date (2022-01-01) %H = hours, %M = minutes, %S = seconds
$ arch="stwl-`date +%F_%H:%M:%S`-.tar.gz"
# Create backup
$ tar -cvzf $bkp/$arch $site
Mark the script executable:
$ chmod +x your_script.sh
Run it manually or use Crontab for scheduled runs.