mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-02-16 17:14:00 +00:00
nixos/tests/restic.nix: add test
This commit is contained in:
parent
5ad71cfe84
commit
42adda1ec4
@ -249,6 +249,7 @@ in
|
||||
radicale = handleTest ./radicale.nix {};
|
||||
redis = handleTest ./redis.nix {};
|
||||
redmine = handleTest ./redmine.nix {};
|
||||
restic = handleTest ./restic.nix {};
|
||||
roundcube = handleTest ./roundcube.nix {};
|
||||
rspamd = handleTest ./rspamd.nix {};
|
||||
rss2email = handleTest ./rss2email.nix {};
|
||||
|
63
nixos/tests/restic.nix
Normal file
63
nixos/tests/restic.nix
Normal file
@ -0,0 +1,63 @@
|
||||
import ./make-test-python.nix (
|
||||
{ pkgs, ... }:
|
||||
|
||||
let
|
||||
password = "some_password";
|
||||
repository = "/tmp/restic-backup";
|
||||
passwordFile = pkgs.writeText "password" "correcthorsebatterystaple";
|
||||
in
|
||||
{
|
||||
name = "restic";
|
||||
|
||||
meta = with pkgs.stdenv.lib.maintainers; {
|
||||
maintainers = [ bbigras ];
|
||||
};
|
||||
|
||||
nodes = {
|
||||
server =
|
||||
{ ... }:
|
||||
{
|
||||
services.restic.backups = {
|
||||
remotebackup = {
|
||||
inherit repository;
|
||||
passwordFile = "${passwordFile}";
|
||||
initialize = true;
|
||||
paths = [ "/opt" ];
|
||||
pruneOpts = [
|
||||
"--keep-daily 2"
|
||||
"--keep-weekly 1"
|
||||
"--keep-monthly 1"
|
||||
"--keep-yearly 99"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
server.start()
|
||||
server.wait_for_unit("dbus.socket")
|
||||
server.fail(
|
||||
"${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots"
|
||||
)
|
||||
server.succeed(
|
||||
"mkdir -p /opt",
|
||||
"touch /opt/some_file",
|
||||
"timedatectl set-time '2016-12-13 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
'${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
|
||||
"timedatectl set-time '2017-12-13 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"timedatectl set-time '2018-12-13 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"timedatectl set-time '2018-12-14 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"timedatectl set-time '2018-12-15 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
"timedatectl set-time '2018-12-16 13:45'",
|
||||
"systemctl start restic-backups-remotebackup.service",
|
||||
'${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
|
||||
)
|
||||
'';
|
||||
}
|
||||
)
|
Loading…
Reference in New Issue
Block a user