diff --git a/docs/releasenotes.rst b/docs/releasenotes.rst index 8b4926be3d6a76923f532886c8de2eb2a9bde38d..734babe0269a0feeecba794a1005687e24db6aae 100644 --- a/docs/releasenotes.rst +++ b/docs/releasenotes.rst @@ -13,6 +13,16 @@ Dropped support for Debian 10 (Buster). * Dropped support for Debian 10 (Buster). +* ``backup_client`` role + + * Previously the backup would run even if pre-backup scripts would + fail. This is no longer the case, and all pre-backup scripts must + exit with non-zero exit code in order for backup process to + kick-in. + * Old backups are now automatically purged after successful + backup. This could lead to longer runtimes for entire backup + process, as well as higher CPU usage. + * ``common`` role * Dropped support for Python 2.7 pip requirements upgrade diff --git a/docs/rolereference.rst b/docs/rolereference.rst index a9327a6f3ca810908e1d411ad884de32f3f3b64e..95f17efbe44fc45134adca31e59c774c324dc26c 100644 --- a/docs/rolereference.rst +++ b/docs/rolereference.rst @@ -2280,6 +2280,9 @@ Duply is configured as follows: * Volume size is set to 1GB. * Pre-backup scripts are run via ``/etc/duply/main/pre`` handler that tries to execute scripts/binaries from directory ``/etc/duply/main/pre.d/``. +* Pre-backup scripts must run successfully for the actual backup + process to proceed. +* Old backups are automatically purged in case of successful run. .. note:: Since at time of this writing there are no lookup plugins for extracting key diff --git a/roles/backup_client/molecule/default/tests/test_default.py b/roles/backup_client/molecule/default/tests/test_default.py index 3c8ab73263e7253cfec484023539ccd633b65736..0659397c318963c813b27f3df10af41ea985b4ec 100644 --- a/roles/backup_client/molecule/default/tests/test_default.py +++ b/roles/backup_client/molecule/default/tests/test_default.py @@ -173,7 +173,7 @@ def test_cron_entry(host): assert cron.user == 'root' assert cron.group == 'root' assert cron.mode == 0o644 - assert cron.content_string == "#Ansible: backup\n0 2 * * * root /usr/bin/duply main backup\n" + assert cron.content_string == "#Ansible: backup\n0 2 * * * root /usr/bin/duply main pre_and_bkp && /usr/bin/duply main post_and_purge --force\n" def test_duply_include_file(host): @@ -202,7 +202,7 @@ def test_backup_and_restore(host): # Remove this file so we can be sure the pre-backup script has been run. host.ansible("file", "path=/var/lib/pre-backup-test state=absent") - backup_run = host.run('duply main backup') + backup_run = host.run('duply main pre_and_bkp') assert backup_run.rc == 0 assert host.file('/var/lib/pre-backup-test').is_file diff --git a/roles/backup_client/tasks/main.yml b/roles/backup_client/tasks/main.yml index d8f4d79bd5a8e73db43ab21939b9f6f69915ed83..dc8c521002661743d0383e7f03d766650f1d6157 100644 --- a/roles/backup_client/tasks/main.yml +++ b/roles/backup_client/tasks/main.yml @@ -131,7 +131,7 @@ cron_file: backup hour: "2" minute: "0" - job: "/usr/bin/duply main backup" + job: "/usr/bin/duply main pre_and_bkp && /usr/bin/duply main post_and_purge --force" state: present user: root