From fadd36625dcdc2d3f0c91de2784bcc9312006eb0 Mon Sep 17 00:00:00 2001 From: Luc Stroobant Date: Sun, 1 Oct 2017 13:13:31 +0200 Subject: [PATCH] remove unused restore script --- defaults/main.yml | 1 - tasks/main.yml | 8 +----- tasks/restore.yml | 42 ----------------------------- templates/borg-restore-from.sh.j2 | 45 ------------------------------- 4 files changed, 1 insertion(+), 95 deletions(-) delete mode 100644 tasks/restore.yml delete mode 100644 templates/borg-restore-from.sh.j2 diff --git a/defaults/main.yml b/defaults/main.yml index efb8154..44ae601 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -1,6 +1,5 @@ --- borgbackup_required: True -borgbackup_do_restore: False borgbackup_version: "1.0.11" borgbackup_checksum: "sha256:fbdc0e0d6d05a0935551f2f408f370236a76b7a30d3bb90a31c3628fe3611359" diff --git a/tasks/main.yml b/tasks/main.yml index 605f061..5f2e9e1 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -3,8 +3,7 @@ - include: install.yml when: > borgbackup_required == True or - inventory_hostname in groups.backupservers or - restore == True + inventory_hostname in groups.backupservers - include: borg-server.yml when: inventory_hostname in groups.backupservers @@ -13,8 +12,3 @@ when: > borgbackup_required == True and inventory_hostname not in groups.backupservers - -- include: restore.yml - when: > - borgbackup_do_restore == True and - inventory_hostname not in groups.backupservers diff --git a/tasks/restore.yml b/tasks/restore.yml deleted file mode 100644 index 64c10a3..0000000 --- a/tasks/restore.yml +++ /dev/null @@ -1,42 +0,0 @@ ---- -- name: client | generate ssh key for this machine - shell: if [ -f ~/.ssh/id_rsa ]; then rm -f ~/.ssh/id_rsa; fi && ssh-keygen -q -t rsa -b 4096 -f ~/.ssh/id_rsa -N "" creates=~/.ssh/id_rsa.pub - -- name: client | fetch ssh-key - shell: cat /root/.ssh/id_rsa.pub - register: sshkey - changed_when: False - -- name: client | write passphrase - lineinfile: - dest: "/root/.borg.passphrase" - state: "present" - line: 'export BORG_PASSPHRASE="{{ borg_passphrase }}"' - create: "yes" - -- name: client | template sshconfig for backup-hosts (no strict key checking) - template: - src: "ssh.config.j2" - dest: "/root/.ssh/config" - owner: "root" - group: "root" - -- name: client | place sshpubkey on the backupserver - authorized_key: - user: "{{ borg_user }}" - key: "{{ sshkey.stdout }}" - key_options: 'command="cd {{ borg_pool }}/{{ restore_from_vm }};borg serve --restrict-to-path {{ borg_pool }}/{{ restore_from_vm }}",no-port-forwarding,no-X11-forwarding,no-pty,no-agent-forwarding,no-user-rc' - delegate_to: "{{ item }}" - with_items: "{{ groups.backupservers }}" - -- name: client | check for mysql - stat: path=/var/lib/automysqlbackup - register: automysql - -- name: client | put wrapper script - template: - src: "borg-restore-from.sh.j2" - dest: "/usr/local/bin/borg-restore-from" - owner: "root" - group: "root" - mode: "0744" diff --git a/templates/borg-restore-from.sh.j2 b/templates/borg-restore-from.sh.j2 deleted file mode 100644 index ce00649..0000000 --- a/templates/borg-restore-from.sh.j2 +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -if [ -z "$1" ] || [ ! -z "$2" ] - then - printf "Possible: info | list | mount \n\n" -fi - -# Sourcing the backup-passphrase - -. /root/.borg.passphrase - -# Small helper commands, like listing backups, will help us in the future :) - -if [ "$1" = "info" ] - then - if [ -z "$2" ]; then printf "run $0 with list and use the backup-tag to request information\n"; exit 1; fi -{% for host in groups.backupservers %} - REPOSITORY={{ borg_user }}@{{ restore_backup_server }}:{{ borg_pool }}/{{ restore_from_vm }} - /usr/local/bin/borg info $REPOSITORY::$2 -{% endfor %} - exit 0 -fi - -if [ "$1" = "mount" ] - then - if [ -z "$2" ]; then printf "Select the backup-server\n"; exit 1; fi - if [ -z "$3" ]; then printf "Select the backup to mount\n"; exit 1; fi - if [ -z "$4" ]; then printf "Select the path to mount the backup on\n"; exit 1; fi -{% for host in groups.backupservers %} - REPOSITORY={{ borg_user }}@{{ restore_backup_server }}:{{ borg_pool }}/{{ restore_from_vm }} - /usr/local/bin/borg mount $REPOSITORY::$3 $4 - if [ "$?" = "0" ]; then printf "Backup mounted on $4, do not forget to unmount!\n"; fi - exit 0 -{% endfor %} -fi - -if [ "$1" = "list" ] - then -{% for host in groups.backupservers %} - REPOSITORY={{ borg_user }}@{{ restore_backup_server }}:{{ borg_pool }}/{{ restore_from_vm }} - printf "{{ restore_from_vm }} archives to restore on {{ host }} ( {{ restore_backup_server }} ):\n" - /usr/local/bin/borg list -v $REPOSITORY -{% endfor %} - exit 0 -fi