Fixing restore-test
This commit is contained in:
parent
01bc64e95c
commit
e1d9aae46e
@ -1 +1 @@
|
||||
../restore/side_effect.yml
|
||||
../generic_files/side_effect.yml
|
@ -1 +1 @@
|
||||
../restore/side_effect.yml
|
||||
../generic_files/side_effect.yml
|
@ -1 +1 @@
|
||||
../restore/side_effect.yml
|
||||
../generic_files/side_effect.yml
|
@ -1 +0,0 @@
|
||||
../restore/restore.sh.j2
|
36
molecule/generic_files/restore.sh.j2
Normal file
36
molecule/generic_files/restore.sh.j2
Normal file
@ -0,0 +1,36 @@
|
||||
#!/bin/sh
|
||||
|
||||
export BORG_PASSPHRASE="{{ borgbackup_passphrase }}"
|
||||
|
||||
last_backup=`/usr/local/bin/borg-backup list | grep '^[0-9]' | awk ' { print $1 } ' | tail -1`
|
||||
|
||||
if [ "$1" = "verify" ]
|
||||
then
|
||||
{% for b in borgbackup_servers %}
|
||||
{% if b.type == 'hetzner' %}
|
||||
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% else %}
|
||||
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% endif %}
|
||||
printf "verifying on {{ b.fqdn }} :\n"
|
||||
/usr/local/bin/borg extract --list --dry-run $REPOSITORY::$last_backup root/sample.txt
|
||||
{% endfor %}
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$1" = "restore" ]
|
||||
then
|
||||
file="$2"
|
||||
{% for b in borgbackup_servers %}
|
||||
{% if b.type == 'hetzner' %}
|
||||
REPOSITORY=ssh://{{ b.user }}@{{ b.fqdn }}:23/./{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% else %}
|
||||
REPOSITORY={{ b.user }}@{{ b.fqdn }}:{{ b.home }}{{ b.pool }}/{{ inventory_hostname }}
|
||||
{% endif %}
|
||||
rm -rf /root/restore/{{ b.fqdn }}
|
||||
mkdir -p /root/restore/{{ b.fqdn }}
|
||||
cd /root/restore/{{ b.fqdn }}
|
||||
/usr/local/bin/borg extract $REPOSITORY::$last_backup root/sample.txt
|
||||
{% endfor %}
|
||||
exit 0
|
||||
fi
|
17
molecule/generic_files/side_effect.yml
Normal file
17
molecule/generic_files/side_effect.yml
Normal file
@ -0,0 +1,17 @@
|
||||
---
|
||||
- hosts: all:!borgbackup_servers
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: generate random file
|
||||
command: dd if=/dev/urandom of=/root/sample.txt bs=1M count=4
|
||||
args:
|
||||
creates: /root/sample.txt
|
||||
- name: template restore test
|
||||
template:
|
||||
src: restore.sh.j2
|
||||
dest: /root/restore.sh
|
||||
mode: "0755"
|
||||
- name: back up
|
||||
command: /usr/local/bin/borg-backup backup
|
||||
- name: restore test file
|
||||
command: /root/restore.sh restore root/sample.txt
|
@ -1 +1 @@
|
||||
../restore/side_effect.yml
|
||||
../generic_files/side_effect.yml
|
@ -1 +1 @@
|
||||
../restore/side_effect.yml
|
||||
../generic_files/side_effect.yml
|
@ -1 +1 @@
|
||||
../restore/side_effect.yml
|
||||
../generic_files/side_effect.yml
|
Loading…
Reference in New Issue
Block a user