-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathbackup.sh
executable file
·42 lines (40 loc) · 1.14 KB
/
backup.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash
set -e
set -o pipefail
while getopts 'v:' OPTION; do
case "$OPTION" in
v)
vault_switch="--vault-password-file=$OPTARG"
;;
?)
echo "script usage: $(basename $0) [-v VaultPasswordfile]" >&2
exit 1
;;
esac
done
shift "$(($OPTIND -1))"
tag="$1"
if [ "$tag" != "" ]
then
backup_swarm="-e backup_name=${tag}_swarm"
backup_ucp="-e backup_name=${tag}_ucp"
backup_dtr_meta="-e backup_name=${tag}_dtr_meta"
backup_dtr_data="-e backup_name=${tag}_dtr_data"
backup_k8s_pvols="-e backup_name=${tag}_k8s_pvols"
else
backup_swarm=""
backup_ucp=""
backup_dtr_meta=""
backup_dtr_data=""
backup_k8s_pvols=""
fi
vswitch=${vault_switch:-}
ansible-playbook -i hosts playbooks/backup_swarm.yml ${vswitch} $backup_swarm
sleep 20
ansible-playbook -i hosts playbooks/backup_ucp.yml ${vswitch} $backup_ucp
sleep 20
ansible-playbook -i hosts playbooks/backup_dtr_metadata.yml ${vswitch} $backup_dtr_meta
sleep 20
ansible-playbook -i hosts playbooks/backup_dtr_images.yml ${vswitch} $backup_dtr_data
sleep 20
ansible-playbook -i hosts playbooks/backup_k8s_pvols.yml ${vswitch} $backup_k8s_pvols