Skip to content

Instantly share code, notes, and snippets.

@stilliard
Last active May 8, 2020 22:24
Show Gist options
  • Save stilliard/3eb9dbe023379265a97a4fff668e48ae to your computer and use it in GitHub Desktop.
Save stilliard/3eb9dbe023379265a97a4fff668e48ae to your computer and use it in GitHub Desktop.
Backup server files with Google Drive
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment