From f1ee1320383832a83c3f67856ef4579169166b06 Mon Sep 17 00:00:00 2001 From: Wojciech Kozlowski Date: Sat, 14 Dec 2019 23:04:28 +0100 Subject: [PATCH] Wrap up B2 setup --- ansible/b2.cred.j2 | 2 +- ansible/loki.yml | 4 ++++ ansible/python.yml | 2 +- b2-backup.sh | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ansible/b2.cred.j2 b/ansible/b2.cred.j2 index 0fcdb8b..4f3dc16 100644 --- a/ansible/b2.cred.j2 +++ b/ansible/b2.cred.j2 @@ -7,4 +7,4 @@ B2_BUCKET="loki-backup" # GPG key (last 8 characters) GPG_KEY="{{ gpg_key_id }}" -PASSPHRASE="{{ gpg_passphrase }}" +GPG_PASSPHRASE="{{ gpg_passphrase }}" diff --git a/ansible/loki.yml b/ansible/loki.yml index cc8fb7a..68f3df4 100644 --- a/ansible/loki.yml +++ b/ansible/loki.yml @@ -97,6 +97,10 @@ apt: name: duplicity + - name: Install B2 backend for duplicity + pip: + name: b2 + - name: Create GitLab credentials file template: src: ./gitlab.cred.j2 diff --git a/ansible/python.yml b/ansible/python.yml index 26a9a77..f2d21d9 100644 --- a/ansible/python.yml +++ b/ansible/python.yml @@ -13,4 +13,4 @@ tasks: - name: Install python2 - raw: apt-get -y install python + raw: apt-get -y install python python-pip python-setuptools diff --git a/b2-backup.sh b/b2-backup.sh index d5ea65d..099ae23 100755 --- a/b2-backup.sh +++ b/b2-backup.sh @@ -9,6 +9,11 @@ export PASSPHRASE=${GPG_PASSPHRASE} # Local directory to backup LOCAL_DIR="/media/usb0/backup" +# Remove files older than 30 days +duplicity remove-older-than 30D --force \ + --encrypt-sign-key $GPG_KEY \ + b2://${B2_ACCOUNT}:${B2_KEY}@${B2_BUCKET} + # Perform a full backup duplicity full \ --encrypt-sign-key $GPG_KEY \