about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2023-11-07 12:00:57 +0000
committerGitHub <noreply@github.com>2023-11-07 12:00:57 +0000
commitbed56440cbc230c9858b0aee045ac5ae9a8ff2c7 (patch)
tree8249a7e712815f4dc707c05a56daa472e181e722 /nixos
parent7eb07191a5fa3207605d78777b95dd70f237fa71 (diff)
parent11e04c904399271e608ecc68c0405ad70ce622a7 (diff)
downloadnixlib-bed56440cbc230c9858b0aee045ac5ae9a8ff2c7.tar
nixlib-bed56440cbc230c9858b0aee045ac5ae9a8ff2c7.tar.gz
nixlib-bed56440cbc230c9858b0aee045ac5ae9a8ff2c7.tar.bz2
nixlib-bed56440cbc230c9858b0aee045ac5ae9a8ff2c7.tar.lz
nixlib-bed56440cbc230c9858b0aee045ac5ae9a8ff2c7.tar.xz
nixlib-bed56440cbc230c9858b0aee045ac5ae9a8ff2c7.tar.zst
nixlib-bed56440cbc230c9858b0aee045ac5ae9a8ff2c7.zip
Merge master into staging-next
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/backup/restic.nix6
-rw-r--r--nixos/tests/restic.nix11
2 files changed, 14 insertions, 3 deletions
diff --git a/nixos/modules/services/backup/restic.nix b/nixos/modules/services/backup/restic.nix
index 49a55d056014..fcdd3082f5a6 100644
--- a/nixos/modules/services/backup/restic.nix
+++ b/nixos/modules/services/backup/restic.nix
@@ -345,7 +345,7 @@ in
             } // optionalAttrs (backup.environmentFile != null) {
               EnvironmentFile = backup.environmentFile;
             };
-          } // optionalAttrs (backup.initialize || backup.dynamicFilesFrom != null || backup.backupPrepareCommand != null) {
+          } // optionalAttrs (backup.initialize || doBackup || backup.backupPrepareCommand != null) {
             preStart = ''
               ${optionalString (backup.backupPrepareCommand != null) ''
                 ${pkgs.writeScript "backupPrepareCommand" backup.backupPrepareCommand}
@@ -360,12 +360,12 @@ in
                 ${pkgs.writeScript "dynamicFilesFromScript" backup.dynamicFilesFrom} >> ${filesFromTmpFile}
               ''}
             '';
-          } // optionalAttrs (backup.dynamicFilesFrom != null || backup.backupCleanupCommand != null) {
+          } // optionalAttrs (doBackup || backup.backupCleanupCommand != null) {
             postStop = ''
               ${optionalString (backup.backupCleanupCommand != null) ''
                 ${pkgs.writeScript "backupCleanupCommand" backup.backupCleanupCommand}
               ''}
-              ${optionalString (backup.dynamicFilesFrom != null) ''
+              ${optionalString doBackup ''
                 rm ${filesFromTmpFile}
               ''}
             '';
diff --git a/nixos/tests/restic.nix b/nixos/tests/restic.nix
index 54fdc1d3995c..868ccb7efd74 100644
--- a/nixos/tests/restic.nix
+++ b/nixos/tests/restic.nix
@@ -4,6 +4,7 @@ import ./make-test-python.nix (
   let
     remoteRepository = "/root/restic-backup";
     remoteFromFileRepository = "/root/restic-backup-from-file";
+    remoteNoInitRepository = "/root/restic-backup-no-init";
     rcloneRepository = "rclone:local:/root/restic-rclone-backup";
 
     backupPrepareCommand = ''
@@ -64,6 +65,11 @@ import ./make-test-python.nix (
                 find /opt -mindepth 1 -maxdepth 1 ! -name a_dir # all files in /opt except for a_dir
               '';
             };
+            remote-noinit-backup = {
+              inherit passwordFile exclude pruneOpts paths;
+              initialize = false;
+              repository = remoteNoInitRepository;
+            };
             rclonebackup = {
               inherit passwordFile paths exclude pruneOpts;
               initialize = true;
@@ -114,6 +120,7 @@ import ./make-test-python.nix (
           "cp -rT ${testDir} /opt",
           "touch /opt/excluded_file_1 /opt/excluded_file_2",
           "mkdir -p /root/restic-rclone-backup",
+          "restic-remote-noinit-backup init",
 
           # test that remotebackup runs custom commands and produces a snapshot
           "timedatectl set-time '2016-12-13 13:45'",
@@ -130,6 +137,10 @@ import ./make-test-python.nix (
           "systemctl start restic-backups-remote-from-file-backup.service",
           'restic-remote-from-file-backup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
 
+          # test that remote-noinit-backup produces a snapshot
+          "systemctl start restic-backups-remote-noinit-backup.service",
+          'restic-remote-noinit-backup snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
+
           # test that restoring that snapshot produces the same directory
           "mkdir /tmp/restore-2",
           "${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} restore latest -t /tmp/restore-2",