From d7fb136d7d752aef8a100854f265d984f79c2ff0 Mon Sep 17 00:00:00 2001 From: Christian Franke Date: Fri, 4 Sep 2015 02:07:14 +0200 Subject: Use s3 to backup/restore git --- roles/gitserver/tasks/main.yaml | 2 +- roles/gitserver/tasks/restore_gitolite.yaml | 34 +++++++++++++++++++++++------ 2 files changed, 28 insertions(+), 8 deletions(-) (limited to 'roles/gitserver/tasks') diff --git a/roles/gitserver/tasks/main.yaml b/roles/gitserver/tasks/main.yaml index 7d1e3d7..aca95f4 100644 --- a/roles/gitserver/tasks/main.yaml +++ b/roles/gitserver/tasks/main.yaml @@ -1,6 +1,6 @@ --- - name: Install gitolite - apt: name={{ item }} + apt: name={{ item }} update_cache=yes with_items: - gitolite3 - git-daemon-run diff --git a/roles/gitserver/tasks/restore_gitolite.yaml b/roles/gitserver/tasks/restore_gitolite.yaml index c937ad1..78a9a0b 100644 --- a/roles/gitserver/tasks/restore_gitolite.yaml +++ b/roles/gitserver/tasks/restore_gitolite.yaml @@ -10,19 +10,34 @@ chdir: /var/lib/gitolite creates: /var/lib/gitolite/.gitolite/conf +#- name: Get repository backup +# get_url: +# url=https://oberon.sublab.org/protected/repositories.tar.gz +# url_username="{{download_user}}" +# url_password="{{download_pass}}" +# validate_certs=no +# dest=/var/lib/gitolite/repositories.tar.gz + - name: Get repository backup - get_url: - url=https://oberon.sublab.org/protected/repositories.tar.gz - url_username="{{download_user}}" - url_password="{{download_pass}}" - validate_certs=no - dest=/var/lib/gitolite/repositories.tar.gz + s3: + bucket=devops-sublab + object=git-backup.tar.asc + dest=/var/lib/gitolite/repositories.tar.asc + mode=get + aws_access_key="{{aws_access_key}}" + aws_secret_key="{{aws_secret_key}}" + region=eu-central-1 + +- name: Decrypt backup + shell: gpg --decrypt --passphrase "{{aws_encryption_key}}" repositories.tar.asc > repositories.tar + args: + chdir: /var/lib/gitolite - name: Create directory for backup unpack file: name=/var/lib/gitolite/old-repositories state=directory - name: Unpack repository backup - shell: tar -x --strip-components=1 -f ../repositories.tar.gz + shell: tar -x --strip-components=1 -f ../repositories.tar args: chdir: /var/lib/gitolite/old-repositories creates: /var/lib/gitolite/old-repositories/gitolite-admin.git @@ -42,3 +57,8 @@ shell: ./restore-backup.sh args: chdir: /var/lib/gitolite + +- name: Cleanup backup + shell: rm -rf repositories.tar.asc repositories.tar old-repositories + args: + chdir: /var/lib/gitolite -- cgit v1.2.1