-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestore_backup.yml
53 lines (46 loc) · 1.37 KB
/
restore_backup.yml
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
43
44
45
46
47
48
49
50
51
52
53
- hosts: base_machines
become: yes
become_user: root
vars:
backup_keys:
- backup.key
- backup.secret.key
aws_keys_file: host_vars/prospero/aws_keys.yml
restore_directory: "" # Specify the directory to restore, e.g., "/username", or leave empty to restore all directories
tasks:
- name: Create restore script
template:
src: files/restore_backup.sh.j2
dest: /root/restore.sh
owner: root
mode: u=rwx,g=,o=
- name: Copy keys
copy:
src: "{{ item }}"
dest: "/root"
with_items: "{{ backup_keys }}"
- name: Install backup keys
shell: "gpg --import /root/{{ item }}"
with_items: "{{ backup_keys }}"
- file:
path: "/root/{{ item }}"
state: absent
with_items: "{{ backup_keys }}"
- name: Install duplicity package
command: "pip install duplicity"
- name: Copy restore script
copy:
src: files/restore.sh
dest: /root/restore.sh
owner: root
group: root
mode: "0700"
- name: Run restore script
command: "bash /root/restore.sh"
environment:
AWS_ACCESS_KEY_ID: "{{ aws_keys.access_key }}"
AWS_SECRET_ACCESS_KEY: "{{ aws_keys.secret_key }}"
when: restore_directory is defined and restore_directory != ""
vars_files:
- secure.yml
- "{{ aws_keys_file }}"