···
5
-
remoteRepository = "/tmp/restic-backup";
6
-
remoteFromFileRepository = "/tmp/restic-backup-from-file";
7
-
rcloneRepository = "rclone:local:/tmp/restic-rclone-backup";
5
+
remoteRepository = "/root/restic-backup";
6
+
remoteFromFileRepository = "/root/restic-backup-from-file";
7
+
rcloneRepository = "rclone:local:/root/restic-rclone-backup";
backupPrepareCommand = ''
10
-
touch /tmp/backupPrepareCommand
11
-
test ! -e /tmp/backupCleanupCommand
10
+
touch /root/backupPrepareCommand
11
+
test ! -e /root/backupCleanupCommand
backupCleanupCommand = ''
15
-
rm /tmp/backupPrepareCommand
16
-
touch /tmp/backupCleanupCommand
15
+
rm /root/backupPrepareCommand
16
+
touch /root/backupCleanupCommand
testDir = pkgs.stdenvNoCC.mkDerivation {
···
inherit passwordFile paths;
repository = "some-fake-repository";
package = pkgs.writeShellScriptBin "restic" ''
84
-
echo "$@" >> /tmp/fake-restic.log;
84
+
echo "$@" >> /root/fake-restic.log;
pruneOpts = [ "--keep-last 1" ];
···
"${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots",
'${pkgs.restic}/bin/restic -r ${remoteFromFileRepository} -p ${passwordFile} snapshots"',
"${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots",
103
-
"grep 'backup.* /opt' /tmp/fake-restic.log",
103
+
"grep 'backup.* /opt' /root/fake-restic.log",
"cp -rT ${testDir} /opt",
"touch /opt/excluded_file_1 /opt/excluded_file_2",
109
-
"mkdir -p /tmp/restic-rclone-backup",
109
+
"mkdir -p /root/restic-rclone-backup",
# test that remotebackup runs custom commands and produces a snapshot
"timedatectl set-time '2016-12-13 13:45'",
"systemctl start restic-backups-remotebackup.service",
114
-
"rm /tmp/backupCleanupCommand",
114
+
"rm /root/backupCleanupCommand",
'${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
# test that restoring that snapshot produces the same directory
···
# test that custompackage runs both `restic backup` and `restic check` with reasonable commandlines
"systemctl start restic-backups-custompackage.service",
132
-
"grep 'backup.* /opt' /tmp/fake-restic.log",
133
-
"grep 'check.* --some-check-option' /tmp/fake-restic.log",
132
+
"grep 'backup.* /opt' /root/fake-restic.log",
133
+
"grep 'check.* --some-check-option' /root/fake-restic.log",
# test that we can create four snapshots in remotebackup and rclonebackup
"timedatectl set-time '2017-12-13 13:45'",
"systemctl start restic-backups-remotebackup.service",
138
-
"rm /tmp/backupCleanupCommand",
138
+
"rm /root/backupCleanupCommand",
"systemctl start restic-backups-rclonebackup.service",
"timedatectl set-time '2018-12-13 13:45'",
"systemctl start restic-backups-remotebackup.service",
143
-
"rm /tmp/backupCleanupCommand",
143
+
"rm /root/backupCleanupCommand",
"systemctl start restic-backups-rclonebackup.service",
"timedatectl set-time '2018-12-14 13:45'",
"systemctl start restic-backups-remotebackup.service",
148
-
"rm /tmp/backupCleanupCommand",
148
+
"rm /root/backupCleanupCommand",
"systemctl start restic-backups-rclonebackup.service",
"timedatectl set-time '2018-12-15 13:45'",
"systemctl start restic-backups-remotebackup.service",
153
-
"rm /tmp/backupCleanupCommand",
153
+
"rm /root/backupCleanupCommand",
"systemctl start restic-backups-rclonebackup.service",
"timedatectl set-time '2018-12-16 13:45'",
"systemctl start restic-backups-remotebackup.service",
158
-
"rm /tmp/backupCleanupCommand",
158
+
"rm /root/backupCleanupCommand",
"systemctl start restic-backups-rclonebackup.service",
'${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',