Bash Shell Script to Backup Webroot on Webserver Performs a full backup of the website document root and creates a tar file for each site. Be sure to edit the configuration options at the beginning of the script to match your environment prior to executing. The end result will be a TAR archive of each website with the name '(current-datestamp)-website-dir-backup-tar.gz'. For Backing up your Website Databases please see our Backup MySQL script.
Usage:
-
Pull up a terminal or SSH into the target server.
-
Logon as root
sudo -i
- Download the installer script.
wget https://raw.githubusercontent.com/clusterednetworks/backup-www/master/backup-www.sh
-
Edit the configuration options at the beginning of the script to match your environment prior to executing.
#---------------------------------------- # OPTIONS #---------------------------------------- DAYS_TO_KEEP=4 # 0 to keep forever WWW_PATH='/var/www' BACKUP_PATH='/home/backup/server05/www' #---------------------------------------
-
Make the script executable
chmod +x backup-www.sh
- Run the script.
./backup-www.sh
- Setup a cronjob to run the script daily/weekly if you choose.
1 1 * * * /etc/backup-www.sh >/dev/null 2>&1