Skip to content

Instantly share code, notes, and snippets.

@scottlinux
Last active March 30, 2024 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save scottlinux/a341ae9128ef18fad6defa45b86ccd7c to your computer and use it in GitHub Desktop.
Save scottlinux/a341ae9128ef18fad6defa45b86ccd7c to your computer and use it in GitHub Desktop.
Google Cloud Nearline Backup Script
#!/usr/bin/env bash
#
# Backup selected directories to a GoogleCloud Nearline bucket
#
# Example daily cron:
# @daily /usr/local/bin/gcbackup >/dev/null
#
# Directories to backup to the cloud
dir=( "/home/stmiller/Documents" "/home/stmiller/Music" \
"/home/stmiller/ownCloud" "/home/stmiller/Pictures" \
"/home/stmiller/Videos" )
# Bucket name
bucket=sweet_gcbucket
# Backup specified directories!
for i in "${dir[@]}" do;
/usr/local/bin/gsutil -m rsync -r -d $i gs://$bucket/$(hostname)$i
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment