Last active
August 29, 2015 13:57
-
-
Save synchrone/9893801 to your computer and use it in GitHub Desktop.
duplicity to s3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
####### | |
# Keep in mind that Ubuntu 14.04 has a little broken python-boto. I found that installing https://launchpad.net/~chris-lea/+archive/ubuntu/python-boto does help | |
###### | |
declare -x S3_USE_SIGV4=True #required for eu-central-1 | |
declare -x AWS_ACCESS_KEY_ID= | |
declare -x AWS_SECRET_ACCESS_KEY= | |
declare -x REMOTE=s3://s3.eu-central-1.amazonaws.com/bucketname | |
#GnuPG | |
declare -x PASSPHRASE="" | |
declare -x KEY_ID=DEADBEEF | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
. ~/.duplicity-config | |
LOG=/var/log/duplicity.log | |
echo "Starting Duplicity backup at `date`" >> $LOG | |
DUP="duplicity --encrypt-key $KEY_ID --full-if-older-than 1M --s3-use-new-style" | |
service mysql stop > /dev/null | |
INFO=$($DUP /var/lib/mysql/ "$REMOTE/mysql" | tee $LOG) | |
service mysql start > /dev/null | |
#send a notification | |
JSON=$(echo "$INFO" | php -r "echo json_encode((object)['event' => 'backup', 'trackers' => ['info' => file_get_contents('php://stdin')]]);") | |
curl -s -o /dev/null -X POST \ | |
-H "x-instapush-appid: " \ | |
-H "x-instapush-appsecret: " \ | |
-H "Content-Type: application/json" \ | |
-d "$JSON" \ | |
https://api.instapush.im/v1/post | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
. ~/.duplicity-config | |
LOG=/var/log/duplicity-roll.log | |
DUP="duplicity --encrypt-key $KEY_ID --s3-use-new-style -v 7" | |
service mysql stop | |
[ -d /var/lib/mysql-before-restore ] && echo "Cannot restore, /var/lib/mysql-before-restore is present" && exit 1 | |
mv /var/lib/mysql /var/lib/mysql-before-restore | |
$DUP "$REMOTE/mysql" /var/lib/mysql/ | tee $LOG | |
service mysql start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment