backup script to google drive that can be used for multiple directories
this zips the content of the target directory and then uploads it to a google drive backup location
just create a file called ~/_backup_dir.sh and then add the following
BASH - _backup_dir.sh
tar -czvf ~/backup/$1.tar.gz /var/www/html/$1/
rclone copy ~/backup/$1.tar.gz gdrive:Backup/my.server.name
make sure you chmod +x the ~/_backup_dir.sh file
then create another file called backup_sites.sh and also chmod +x this file
Now we can list the directories we want to zip and upload to google drive.
BASH - backup_sites.sh
and then when you add a new directory that needs to be backed up to google drive, just add it to the backup_sites.sh file and it will add it to the list.
Also if you want to have automated backups you can now add the backup_sites.sh to a crontab and specify when you want it to run to automatically backup your files.
Add this to your crontab to backup all sites daily at 8.
BASH - crontab
0 8 * * * ~/backup_all.sh > /dev/null 2>&1