add systemd units
This commit is contained in:
parent
18ec0569c8
commit
aafcb1ad50
5 changed files with 18 additions and 4 deletions
|
@ -77,20 +77,22 @@
|
|||
|
||||
- name: "Template systemd units for restic"
|
||||
ansible.builtin.template:
|
||||
src: "restic-wasabi.service.j2"
|
||||
src: "restic.service.j2"
|
||||
dest: "/etc/systemd/system/restic@.service"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 'u+rwx'
|
||||
register: unit
|
||||
when: "ansible_os_family == 'Debian'"
|
||||
|
||||
- name: "Template systemd timers for restic"
|
||||
ansible.builtin.template:
|
||||
src: "restic-wasabi.timer.j2"
|
||||
src: "restic.timer.j2"
|
||||
dest: "/etc/systemd/system/restic@.timer"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 'u+rwx'
|
||||
register: unit
|
||||
when: "ansible_os_family == 'Debian'"
|
||||
|
||||
- name: "Reload systemd units"
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/bin/bash
|
||||
source /opt/scripts/restic/restic.env
|
||||
source /opt/scripts/restic/restic_db_passwords.env
|
||||
|
||||
#We will have to find out whether or not we need to initialize the repo. A non-zero exit code indicates that it has not yet been initialized.
|
||||
restic snapshots
|
||||
if [ "$?" -eq "0" ]
|
||||
|
@ -12,9 +14,9 @@ fi
|
|||
echo "Now dumping databases, this might take a while..."
|
||||
set -x
|
||||
docker exec -t pretix_pg-sql.server2 pg_dumpall -c -U prtxdb > /opt/db_dumps/db-dump-pretix_db.sql
|
||||
#docker exec docker-partkeepr-database-1 sh -c "exec mariadb-dump --all-databases -u{{ unhb4_mariadb_containers['partkeepr'].user }} --password=$MARIADB_PASSWORD_PARTKEEPR" > /opt/db_dumps/db-dump-partkeepr_db.sql
|
||||
source /opt/scripts/restic/restic_db_passwords.env
|
||||
docker exec -t engel_sql.server2 sh -c "exec mysqldump --all-databases -u{{ unhb4_mariadb_containers['engelsystem'].user }} --password=$MARIADB_PASSWORD_ENGELSYSTEM" > /opt/db_dumps/db-dump-engelsystem_db.sql
|
||||
docker exec -t engel_sql.server2 sh -c "exec mysqldump --all-databases -uroot --password=$MARIADB_PASSWORD_ENGELSYSTEM" > /opt/db_dumps/db-dump-engelsystem_db.sql
|
||||
|
||||
set +x
|
||||
|
||||
restic backup --verbose \
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
{{ restic_password_repo[inventory_hostname]["password"] }}
|
6
roles/unhb_backup_scripts/templates/restic-prune.sh.j2
Executable file
6
roles/unhb_backup_scripts/templates/restic-prune.sh.j2
Executable file
|
@ -0,0 +1,6 @@
|
|||
#!/bin/bash
|
||||
source /opt/scripts/restic/restic.env
|
||||
|
||||
restic forget --prune --keep-within 1m --host={{ ansible_hostname }}
|
||||
|
||||
echo "done! :)"
|
3
roles/unhb_backup_scripts/templates/restic.env.j2
Executable file
3
roles/unhb_backup_scripts/templates/restic.env.j2
Executable file
|
@ -0,0 +1,3 @@
|
|||
#!/bin/bash
|
||||
export RESTIC_REPOSITORY="{{ restic_repository_location }}{{ inventory_hostname }}"
|
||||
export RESTIC_PASSWORD_FILE="/opt/scripts/restic/restic-password-repo"
|
Loading…
Reference in a new issue