Posted in linux
5:26 am, May 26, 2021

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 ~/ and then add the following


tar -czvf ~/backup/$1.tar.gz /var/www/html/$1/
rclone copy ~/backup/$1.tar.gz gdrive:Backup/

make sure you chmod +x the ~/ file

then create another file called and also chmod +x this file

Now we can list the directories we want to zip and upload to google drive.



and then when you add a new directory that needs to be backed up to google drive, just add it to the file and it will add it to the list.

Also if you want to have automated backups you can now add the 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 * * * ~/ > /dev/null 2>&1

No Items Found.

Add Comment
Type in a Nick Name here
Page Views

This page has been viewed 198 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
time you enjoyed wasting is not wasted time