Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save geekpete/ebcb2e2b4c4d7caf857d4b12c4b3d4d3 to your computer and use it in GitHub Desktop.
Save geekpete/ebcb2e2b4c4d7caf857d4b12c4b3d4d3 to your computer and use it in GitHub Desktop.
Backup script for backblaze b2
#!/usr/bin/env bash
#
# Backup selected directories to a Backblaze B2 bucket
#
# Example daily cron:
# @daily /usr/local/bin/b2backup >/dev/null
#
# Account creds
id=xxxxxxxxxx
key=xxxxxxxxxxxxxxxx
# Threads
threads=5
# Directories to backup, and the name of their subdirectory in the bucket
declare -A dir
dir=(["/var/backups"]="backups" ["/var/www"]="www")
# Bucket name
bucket=linode
for i in "${!dir[@]}" do;
/usr/local/bin/b2sync -rxt$threads $id $key "$i" $bucket:"${dir["$i"]}"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment