# ref: https://github.com/prasmussen/gdrive
# prerequisite:
# In google drive, setup your folder for storing the backups
# Then grab the code from the url e.g. https://drive.google.com/drive/folders/xxxxx where xxxxx is the code
# This code will be used later in the cron command, keep it secret, keep it safe
# install gdrive sync for backups
wget https://drive.google.com/uc?id=0B3X9GlR6EmbnQ0FtZmJJUXEyRTA -O /usr/local/bin/gdrive
chmod 755 /usr/local/bin/gdrive
# setup connection (this will ask you to visit a url in your browser and accept permissions for gdrive, then it'll give you an access code you copy and paste back over in the terminal)
gdrive about
# setup files to be backed up as links into a /backup directory
# e.g. to backup a few core log files:
mkdir /backup
ln /var/log/auth.log /backup
ln /var/log/syslog /backup
ln /var/log/mysql/error.log /backup
ln /var/log/nginx/error.log /backup
ln /var/log/php7.0-fpm.log /backup
# ** worth spening a little time reviewing what you want to backup **
# use cron to regularly sync /backup directory
crontab -e
# add the following
@daily /usr/local/bin/gdrive sync upload --delete-extraneous /backup xxxxx > /dev/null