Skip to content

Instantly share code, notes, and snippets.

@law
Created January 26, 2015 07:23
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save law/e4091aa2e481cf4fa026 to your computer and use it in GitHub Desktop.
Save law/e4091aa2e481cf4fa026 to your computer and use it in GitHub Desktop.
#!/bin/bash
DUPLICITY=/usr/local/bin/duplicity
S3CFG=/var/backups/.s3cfg
S3DST=s3+http://<mys3endpoint>/cloud-data
GPGID=<mygpgid from 'gpg --list-keys'>
SOURCE=/var/backups/snapshots/storage/data/ # I have my 'important' stuff on an LVM volume so I can snapshot to quiesce the disk if needed
# Read .s3cfg (part of the 's3cmd' package), set variables (after some munging) from that config file
eval $(grep key $S3CFG | tr -s ' =' = | tr '\n' '; ')
# Set the environment variables duplicity expects, from the parsing of $S3CFG
export AWS_ACCESS_KEY_ID=$access_key
export AWS_SECRET_ACCESS_KEY=$secret_key
/sbin/lvcreate -L5G -s -n storagesnap /dev/vol1/storage
/bin/mount /dev/vol1/storagesnap /var/backups/snapshots/storage
$DUPLICITY -v4 --s3-use-new-style \
--full-if-older-than 1M \
--encrypt-key $GPGID \
--gpg-options="--always-trust" \
--volsize 512 \
--s3-use-multiprocessing \
--s3-multipart-chunk-size 128 \
--s3-multipart-max-procs 4 \
--asynchronous-upload \
$SOURCE $S3DST
/bin/umount /var/backups/snapshots/storage
/sbin/lvremove -f /dev/vol1/storagesnap
# Clear the environment variables
export AWS_ACCESS_KEY_ID=' '
export AWS_SECRET_ACCESS_KEY=' '
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment