Last active
January 31, 2018 10:46
-
-
Save molobrakos/ff1620ce6031c99f120b to your computer and use it in GitHub Desktop.
using duplicity with hubic to backup home directory on ubuntu linux
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
# preparations | |
# ------------ | |
# create a new application in hubic account manager | |
# visit https://hubic.com/home/browser/account/ | |
# Developers > Add an application | |
# Name: backup | |
# Redirection domain: http://localhost/ | |
# copy "Client ID" and "Secret Client", it will be used later | |
sudo apt-get install librsync-dev libffi-dev python-virtualenv python-swiftclient | |
# install duplicity | |
# ----------------- | |
# to avoid having to mess with dependencies, package versions etc, | |
# just install the latest version of duplicity locally in | |
# $HOME/.backup | |
# this version supports hubic, using the pyrax library | |
BAKDIR=$HOME/.backup | |
DUPENV=dupenv | |
mkdir -p $BAKDIR | |
cd $BAKDIR | |
virtualenv $DUPENV | |
source ./$DUPENV/bin/activate | |
pip install lockfile pyrax requests oslo.config netifaces pytz msgpack-python | |
curl -O -L https://code.launchpad.net/duplicity/0.7-series/0.7.02/+download/duplicity-0.7.02.tar.gz | |
tar xfzv duplicity-0.7.02.tar.gz | |
cd duplicity-0.7.02 | |
./setup.py install | |
CREDZ=$HOME/.hubic_credentials | |
cat > $CREDZ <<END | |
[hubic] | |
email = user@example.com | |
password = password | |
client_id = clent id from hubic | |
client_secret = client secret from hubic | |
redirect_uri = http://localhost/ | |
END | |
chmod og-rwx $CREDZ | |
# to make a backup (this can be added to crontab) | |
# ----------------------------------------------- | |
export DUPLICITY="nice $HOME/.backup/dupenv/bin/duplicity" | |
export PASSPHRASE="secret-backup-password" | |
export DST="cf+hubic://bak-hostname" | |
export NAME="hostname-home" | |
$DUPLICITY --name $NAME --full-if-older-than 4W --volsize 500 --asynchronous-upload --exclude $HOME/.cache $HOME $DST/home | |
$DUPLICITY --name $NAME remove-older-than 12W $DST/home | |
$DUPLICITY --name $NAME collection-status $DST/home | |
# to check the status of the remote repository | |
# -------------------------------------------- | |
# since files won't show up in the hubic browser we use this script | |
# which provides ls-like functionality | |
source ./$DUPENV/bin/activate | |
cd lib | |
git clone https://github.com/puzzle1536/hubic-wrapper-to-swift | |
pip install -r hubic-wrapper-to-swift/requirements.txt | |
# this script uses very similar config format as pyrax above, | |
# the only difference is the use of email vs username | |
# just provide both keys in the config file | |
ln -s ~/.hubic_credentials ~/.hubic.cfg | |
# create a new container | |
./hubic.py --swift -- post bak-hostname | |
# list all containers | |
./hubic.py --swift -- list --long | |
# list contents of a container | |
./hubic.py --swift -- list --lh bak-hostname |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment