Skip to content

Instantly share code, notes, and snippets.

@brantfaircloth
Created May 6, 2011 07:07
Show Gist options
  • Save brantfaircloth/958544 to your computer and use it in GitHub Desktop.
Save brantfaircloth/958544 to your computer and use it in GitHub Desktop.
Duplicity backups to S3
#!/bin/bash
#
# duplicity_backup_to_s3.sh
#
# Created by Brant Faircloth on 2011-05-05.
# Copyright (c) 2011 Brant Faircloth. All rights reserved.
#
# Run by cron w/
# 0 2 * * * /path/to/duplicity_backup_to_s3.sh 2>&1 >> /var/log/duplicity/etc.log
#
#!/bin/sh
export PASSPHRASE=my_password
export AWS_ACCESS_KEY_ID=my_aws_access_key_id
export AWS_SECRET_ACCESS_KEY=my_aws_secret_access_key
GPG_KEY=my_gpg_key
DEST=s3+http://my.bucketname
# Delete older than 1 month
duplicity remove-older-than 1M --force --encrypt-key=${GPG_KEY} --sign-key=${GPG_KEY} ${DEST}
# Cleanup stale files
duplicity cleanup --extra-clean --force --encrypt-key=${GPG_KEY} --sign-key=${GPG_KEY} ${DEST}
# Exclude everything, adding only what we want
duplicity \
--full-if-older-than 1M \
--encrypt-key=${GPG_KEY} \
--sign-key=${GPG_KEY} \
--include /home/backuser/backups \
--exclude '**' \
/ ${DEST}
export PASSPHRASE=
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