Posted in linux
4522
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 ~/_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

#files
~/_backup_dir.sh my.site.one
~/_backup_dir.sh my.site.two

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

View Statistics
This Week
134
This Month
481
This Year
587

No Items Found.

Add Comment
Type in a Nick Name here
 
Search Code
Search Code by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
For a long time it had seemed to me that life was about to begin - real life. But there was always some obstacle in the way, something to be gotten through first, some unfinished business, time still to be served, or a debt to be paid. Then life would begin. At last it dawned on me that these obstacles were my life.
Alfred D. Souza
Random CSS Property

brightness()

The brightness() CSS function applies a linear multiplier to the input image, making it appear brighter or darker. Its result is a <filter-function>.
brightness() css reference