Skip to content
GitLab
Explore
Sign in
Register
Pâquerette
Infrastructure
Ansible Pâquerette
Compare revisions
285a3f7888491d4da2e895da2e30877a0a10945c to 813a5a48af4377ddb66a05b2a4c4966aae068def
Commits on Source (2)
[wip] add restore of db
· 84ffa44d
Julien Gomes Dias
authored
Dec 30, 2021
84ffa44d
[wip] add restore of db
· 813a5a48
Julien Gomes Dias
authored
Dec 30, 2021
813a5a48
Hide whitespace changes
Inline
Side-by-side
roles/restic/README.md
View file @
813a5a48
...
...
@@ -23,7 +23,7 @@ restic:
hour: '3'
stdin:
- database: 'mysqldump -u piwik -p$MYSQLPASSWORD 127.0.0.1'
filename: '
matomo
.sql'
filename: '
production
.sql'
- name: 'local-mastodon'
repository: '/srv/backups/restic_mastodon-backup'
cron:
...
...
roles/restic/tasks/install.yml
View file @
813a5a48
...
...
@@ -5,8 +5,10 @@
name
:
bzip2
state
:
latest
register
:
apt_info
-
name
:
Display stdout of apt
debug
:
msg={{ apt_info.stdout.split('\n')[:-1] }}
debug
:
msg
:
"
{{
apt_info.stdout.split('
\n
')[:-1]
}}"
when
:
apt_info is changed
-
name
:
Get checksum for restic
...
...
roles/restic/tasks/restore.yml
View file @
813a5a48
...
...
@@ -17,41 +17,47 @@
-
list_backups
-
name
:
Restore snapshot
block
:
-
name
:
Restore latest in tmp
shell
:
"
restic
restore
latest
--target
/tmp
--path
\"
{{
item.1.folder
}}
\"
"
when
:
snapshot_id is not defined and item.0.type == snapshot_type
loop
:
"
{{
restic.backups|subelements('folders')
}}"
environment
:
RESTIC_PASSWORD
:
"
{{
restic_password
}}"
-
name
:
Restore snapshot_id in tmp
shell
:
"
restic
restore
-r
{{
item.repository
}}
{{
snapshot_id
}}
--target
/tmp"
when
:
snapshot_id is defined and item.type == snapshot_type
loop
:
"
{{
restic.backups
}}"
environment
:
RESTIC_PASSWORD
:
"
{{
restic_password
}}"
-
name
:
backup before instance deletion of the folder
command
:
"
bash
/root/scripts/restic_backup_{{
snapshot_type
}}-{{
app_instance_id
}}.sh"
-
name
:
Restore /tmp/{{ item.folder }}
copy
:
remote_src
:
true
force
:
yes
src
:
"
/tmp/{{
snapshot_folder
}}"
dest
:
"
{{
snapshot_folder
}}/.."
owner
:
"
{{
app_user
}}"
group
:
"
{{
app_group
}}"
when
:
snapshot_id is defined and item.type == snapshot_type
loop
:
"
{{
restic.backups
}}"
-
name
:
Restore /tmp/{{ item.folder }}
copy
:
remote_src
:
true
force
:
yes
src
:
"
/tmp/{{
item.1.folder
}}"
dest
:
"
{{
item.1.folder
}}/.."
owner
:
"
{{
app_user
}}"
group
:
"
{{
app_group
}}"
when
:
snapshot_id is not defined and item.0.type == snapshot_type
loop
:
"
{{
restic.backups|subelements('folders')
}}"
-
name
:
Restore files
block
:
-
name
:
Restore latest in tmp
shell
:
"
restic
restore
latest
--target
/tmp
--path
\"
{{
item.1.folder
}}
\"
"
when
:
snapshot_id is not defined and item.0.type == snapshot_type
loop
:
"
{{
restic.backups|subelements('folders')
}}"
environment
:
RESTIC_PASSWORD
:
"
{{
restic_password
}}"
-
name
:
Restore snapshot_id in tmp
shell
:
"
restic
restore
-r
{{
item.repository
}}
{{
snapshot_id
}}
--target
/tmp"
when
:
snapshot_id is defined and item.type == snapshot_type
loop
:
"
{{
restic.backups
}}"
environment
:
RESTIC_PASSWORD
:
"
{{
restic_password
}}"
-
name
:
backup before instance deletion of the folder
command
:
"
bash
/root/scripts/restic_backup_{{
snapshot_type
}}-{{
app_instance_id
}}.sh"
-
name
:
Restore /tmp/{{ item.folder }}
copy
:
remote_src
:
true
force
:
yes
src
:
"
/tmp/{{
snapshot_folder
}}"
dest
:
"
{{
snapshot_folder
}}/.."
owner
:
"
{{
app_user
}}"
group
:
"
{{
app_group
}}"
when
:
snapshot_id is defined and item.type == snapshot_type
loop
:
"
{{
restic.backups
}}"
-
name
:
Restore /tmp/{{ item.folder }}
copy
:
remote_src
:
true
force
:
yes
src
:
"
/tmp/{{
item.1.folder
}}"
dest
:
"
{{
item.1.folder
}}/.."
owner
:
"
{{
app_user
}}"
group
:
"
{{
app_group
}}"
when
:
snapshot_id is not defined and item.0.type == snapshot_type
loop
:
"
{{
restic.backups|subelements('folders')
}}"
-
name
:
Restore db if needed
block
:
# Database
-
name
:
Restore db snapshot if needed
shell
:
"
restic
-r
{{
item.repository
}}
dump
{{
snapshot_id
}}
{{
item.filename
}}.sql
|
mysql"
when
:
snapshot_id is not defined and item.0.type == snapshot_type and data_type = mariadb
loop
:
"
{{
restic.backups
}}"
when
:
snapshots_list is not defined
tags
:
-
restore_backup
roles/rocketchat_instance/tasks/main.yml
View file @
813a5a48
...
...
@@ -9,7 +9,8 @@
-
import_tasks
:
uninstall.yml
when
:
app_run == 'uninstall'
-
block
:
-
name
:
Set up service
block
:
-
name
:
"
stop
service
{{
app_service
}}"
systemd
:
...
...