diff options
author | Otavio Salvador <otavio@ossystems.com.br> | 2022-06-02 13:43:03 -0300 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2022-06-03 11:22:22 -0300 |
commit | d9e3b1fafe3c1509a886fb8795b3438c7caa07f5 (patch) | |
tree | fec5ab4990a46cc44e9912e055a58eac7658546d /nixos/tests | |
parent | deae887c5a497a978b55b205dff9c517eb0df55e (diff) |
nixos/restic: add backup{Prepare,Cleanup}Command options
The backupPrepareCommand and backupCleanupCommand options offer a way to run a script to prepare for backup and then cleanup it once finish. Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
Diffstat (limited to 'nixos/tests')
-rw-r--r-- | nixos/tests/restic.nix | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/nixos/tests/restic.nix b/nixos/tests/restic.nix index 16d7edde0c1c4..7523d5e5ed5da 100644 --- a/nixos/tests/restic.nix +++ b/nixos/tests/restic.nix @@ -7,6 +7,16 @@ import ./make-test-python.nix ( repositoryFile = "${pkgs.writeText "repositoryFile" "/tmp/restic-backup-from-file"}"; rcloneRepository = "rclone:local:/tmp/restic-rclone-backup"; + backupPrepareCommand = '' + touch /opt/backupPrepareCommand + test ! -e /opt/backupCleanupCommand + ''; + + backupCleanupCommand = '' + rm /opt/backupPrepareCommand + touch /opt/backupCleanupCommand + ''; + passwordFile = "${pkgs.writeText "password" "correcthorsebatterystaple"}"; initialize = true; paths = [ "/opt" ]; @@ -30,7 +40,7 @@ import ./make-test-python.nix ( { services.restic.backups = { remotebackup = { - inherit repository passwordFile initialize paths pruneOpts; + inherit repository passwordFile initialize paths pruneOpts backupPrepareCommand backupCleanupCommand; }; remotebackup-from-file = { inherit repositoryFile passwordFile initialize paths pruneOpts; @@ -73,6 +83,7 @@ import ./make-test-python.nix ( "mkdir -p /tmp/restic-rclone-backup", "timedatectl set-time '2016-12-13 13:45'", "systemctl start restic-backups-remotebackup.service", + "rm /opt/backupCleanupCommand", "systemctl start restic-backups-remotebackup-from-file.service", "systemctl start restic-backups-rclonebackup.service", '${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"', @@ -80,18 +91,23 @@ import ./make-test-python.nix ( '${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"', "timedatectl set-time '2017-12-13 13:45'", "systemctl start restic-backups-remotebackup.service", + "rm /opt/backupCleanupCommand", "systemctl start restic-backups-rclonebackup.service", "timedatectl set-time '2018-12-13 13:45'", "systemctl start restic-backups-remotebackup.service", + "rm /opt/backupCleanupCommand", "systemctl start restic-backups-rclonebackup.service", "timedatectl set-time '2018-12-14 13:45'", "systemctl start restic-backups-remotebackup.service", + "rm /opt/backupCleanupCommand", "systemctl start restic-backups-rclonebackup.service", "timedatectl set-time '2018-12-15 13:45'", "systemctl start restic-backups-remotebackup.service", + "rm /opt/backupCleanupCommand", "systemctl start restic-backups-rclonebackup.service", "timedatectl set-time '2018-12-16 13:45'", "systemctl start restic-backups-remotebackup.service", + "rm /opt/backupCleanupCommand", "systemctl start restic-backups-rclonebackup.service", '${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"', '${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"', |