#!/bin/sh # ssh://git.mdcc.cx/git/ad1810-stuff.git # ( view recent version online at http://mdcc.cx/git/wd/ad1810-stuff/scripts/a1-s3dup ) # # This file is in the public domain. # Author: Joost van Baal-Ilić, march 2014 # Inspired upon an idea by Thomas Sileo # ( see https://gist.github.com/tsileo/3147209 and # http://thomassileo.com/blog/2012/07/19/ubuntu-slash-debian-encrypted-incremental-backups-with-duplicity-on-amazon-s3/ ) # # # needed software # apt -V install duplicity # # example configuration file # # cat </usr/local/etc/a1-s3dup.conf # AWS_ACCESS_KEY_ID=ABCDEFGHIJKLMNOPQRST # AWS_SECRET_ACCESS_KEY=A1b2C3d4EfGhIjKlMnOPq5r6s7t8u9v0WxYz1a2B # BUCKET=s3+http://foo.systems.bar.s3.amazonaws.com # PASSPHRASE=s3kr3+Pa5s # EOT # # enable to be run from cron: # # cat </etc/cron.d/a1-s3dup # PATH=/usr/local/bin:/usr/bin:/bin # MAILTO=root # @daily a1-s3dup a1-s3dup # EOT # # in order to restore a file, first set up environment: # # # su - a1-s3dup # $ . /usr/local/etc/a1-s3dup.conf # $ export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY PASSPHRASE # # then, if you e.g. would like to have a copy of the file # /etc/apt/apt.conf.d/99local as it was on 2014-05-01, and you'd like to store # this copy in /var/tmp/99local, you'd do: # # $ duplicity restore --file-to-restore etc/apt/apt.conf.d/99local --time 2014-05-01 $BUCKET /var/tmp/99local # # CONFFILE=/usr/local/etc/a1-s3dup.conf if test -f $CONFFILE then . $CONFFILE else echo >&2 "a1-s3dup: error: configuration file $CONFFILE missing" exit 1 fi # these should be set in $CONFFILE export AWS_ACCESS_KEY_ID AWS_SECRET_ACCESS_KEY PASSPHRASE export BUCKET dirs=$( cat <