Skip to content

Instantly share code, notes, and snippets.

@scottlinux
Last active November 6, 2019 23:12
Show Gist options
  • Save scottlinux/362e672aaac45e00e40f to your computer and use it in GitHub Desktop.
Save scottlinux/362e672aaac45e00e40f 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
@AlexanderProd
Copy link

Is this still compatible with the latest version of the b2 cli tool?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment