restic
This commit is contained in:
@@ -5,3 +5,14 @@
|
|||||||
- name: 'wget {{url}} -O - | bzip2 -cd > /bin/restic ; chmod +x /bin/restic'
|
- name: 'wget {{url}} -O - | bzip2 -cd > /bin/restic ; chmod +x /bin/restic'
|
||||||
- unless: stat /bin/restic
|
- unless: stat /bin/restic
|
||||||
|
|
||||||
|
/opt/restic_backups.sh:
|
||||||
|
file.managed:
|
||||||
|
- source: 'salt://restic/files/restic_backup.sh.jinja'
|
||||||
|
- template: jinja
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- mode: 0700
|
||||||
|
cron.present:
|
||||||
|
- minute: 20
|
||||||
|
- hour: 4
|
||||||
|
- dayweek: 0
|
||||||
|
|||||||
12
restic/files/restic_backup.sh.jinja
Normal file
12
restic/files/restic_backup.sh.jinja
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
export HOME=/root
|
||||||
|
export RESTIC_PASSWORD={{ salt.pillar.get('restic:pass') }}
|
||||||
|
export RESTIC_REPOSITORY={{ salt.pillar.get('restic:repo') }}
|
||||||
|
restic backup --tag files {{ salt.pillar.get('restic:files') }}
|
||||||
|
{% if salt.pillar.get('restic:mysql', False) -%}
|
||||||
|
mysqldump --all-databases | restic backup --stdin --stdin-filename /all_databases.sql --tag mysql
|
||||||
|
{% endif -%}
|
||||||
|
restic forget --keep-last 4 --tag mysql --prune
|
||||||
|
{% if salt.pillar.get('restic:mysql', False) -%}
|
||||||
|
restic forget --keep-last 4 --tag files --prune
|
||||||
|
{% endif -%}
|
||||||
4
top.sls
4
top.sls
@@ -3,6 +3,9 @@
|
|||||||
- common
|
- common
|
||||||
- users
|
- users
|
||||||
- salt.minion
|
- salt.minion
|
||||||
|
{% if salt.pillar.get('restic', None) is not none %}
|
||||||
|
- restic.client
|
||||||
|
{% endif %}
|
||||||
'*.keiran.us':
|
'*.keiran.us':
|
||||||
- net
|
- net
|
||||||
'vps47492.inmotionhosting.com':
|
'vps47492.inmotionhosting.com':
|
||||||
@@ -12,5 +15,4 @@
|
|||||||
- icinga2
|
- icinga2
|
||||||
- nginx
|
- nginx
|
||||||
- restic.server
|
- restic.server
|
||||||
- restic.client
|
|
||||||
- samba
|
- samba
|
||||||
|
|||||||
Reference in New Issue
Block a user