Skip to content

Instantly share code, notes, and snippets.

@Wizek
Forked from scottlinux/backblaze b2 backup script
Created August 29, 2017 23:10
Show Gist options
  • Save Wizek/1a34c58d83fa49c68bb3320ad1991f55 to your computer and use it in GitHub Desktop.
Save Wizek/1a34c58d83fa49c68bb3320ad1991f55 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