mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-14 14:10:33 +03:00
nixos/tests/restic: test that restoring works
This commit also moves the indicator files out of the directory that's being backed up, so that the directory remains static throughout the backup operation.
This commit is contained in:
parent
751b9063a7
commit
2a46ef4fff
1 changed files with 25 additions and 12 deletions
|
@ -7,15 +7,24 @@ import ./make-test-python.nix (
|
|||
rcloneRepository = "rclone:local:/tmp/restic-rclone-backup";
|
||||
|
||||
backupPrepareCommand = ''
|
||||
touch /opt/backupPrepareCommand
|
||||
test ! -e /opt/backupCleanupCommand
|
||||
touch /tmp/backupPrepareCommand
|
||||
test ! -e /tmp/backupCleanupCommand
|
||||
'';
|
||||
|
||||
backupCleanupCommand = ''
|
||||
rm /opt/backupPrepareCommand
|
||||
touch /opt/backupCleanupCommand
|
||||
rm /tmp/backupPrepareCommand
|
||||
touch /tmp/backupCleanupCommand
|
||||
'';
|
||||
|
||||
testDir = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "test-files-to-backup";
|
||||
unpackPhase = "true";
|
||||
installPhase = ''
|
||||
mkdir $out
|
||||
touch $out/some_file
|
||||
'';
|
||||
};
|
||||
|
||||
passwordFile = "${pkgs.writeText "password" "correcthorsebatterystaple"}";
|
||||
paths = [ "/opt" ];
|
||||
pruneOpts = [
|
||||
|
@ -94,16 +103,20 @@ import ./make-test-python.nix (
|
|||
)
|
||||
server.succeed(
|
||||
# set up
|
||||
"mkdir -p /opt",
|
||||
"touch /opt/some_file",
|
||||
"cp -rT ${testDir} /opt",
|
||||
"mkdir -p /tmp/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",
|
||||
"rm /opt/backupCleanupCommand",
|
||||
"rm /tmp/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
|
||||
"mkdir /tmp/restore-1",
|
||||
"${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} restore latest -t /tmp/restore-1",
|
||||
"diff -ru ${testDir} /tmp/restore-1/opt",
|
||||
|
||||
# test that remote-from-file-backup produces a snapshot
|
||||
"systemctl start restic-backups-remote-from-file-backup.service",
|
||||
'${pkgs.restic}/bin/restic -r ${remoteFromFileRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 1"',
|
||||
|
@ -120,27 +133,27 @@ import ./make-test-python.nix (
|
|||
# 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",
|
||||
"rm /opt/backupCleanupCommand",
|
||||
"rm /tmp/backupCleanupCommand",
|
||||
"systemctl start restic-backups-rclonebackup.service",
|
||||
|
||||
"timedatectl set-time '2018-12-13 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"rm /opt/backupCleanupCommand",
|
||||
"rm /tmp/backupCleanupCommand",
|
||||
"systemctl start restic-backups-rclonebackup.service",
|
||||
|
||||
"timedatectl set-time '2018-12-14 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"rm /opt/backupCleanupCommand",
|
||||
"rm /tmp/backupCleanupCommand",
|
||||
"systemctl start restic-backups-rclonebackup.service",
|
||||
|
||||
"timedatectl set-time '2018-12-15 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"rm /opt/backupCleanupCommand",
|
||||
"rm /tmp/backupCleanupCommand",
|
||||
"systemctl start restic-backups-rclonebackup.service",
|
||||
|
||||
"timedatectl set-time '2018-12-16 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"rm /opt/backupCleanupCommand",
|
||||
"rm /tmp/backupCleanupCommand",
|
||||
"systemctl start restic-backups-rclonebackup.service",
|
||||
|
||||
'${pkgs.restic}/bin/restic -r ${remoteRepository} -p ${passwordFile} snapshots --json | ${pkgs.jq}/bin/jq "length | . == 4"',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue