nixos/tests: Add rclone repository to restic test
This commit is contained in:
parent
7dd656a037
commit
9b80955720
|
@ -4,33 +4,50 @@ import ./make-test-python.nix (
|
||||||
let
|
let
|
||||||
password = "some_password";
|
password = "some_password";
|
||||||
repository = "/tmp/restic-backup";
|
repository = "/tmp/restic-backup";
|
||||||
passwordFile = pkgs.writeText "password" "correcthorsebatterystaple";
|
rcloneRepository = "rclone:local:/tmp/restic-rclone-backup";
|
||||||
|
|
||||||
|
passwordFile = "${pkgs.writeText "password" "correcthorsebatterystaple"}";
|
||||||
|
initialize = true;
|
||||||
|
paths = [ "/opt" ];
|
||||||
|
pruneOpts = [
|
||||||
|
"--keep-daily 2"
|
||||||
|
"--keep-weekly 1"
|
||||||
|
"--keep-monthly 1"
|
||||||
|
"--keep-yearly 99"
|
||||||
|
];
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
name = "restic";
|
name = "restic";
|
||||||
|
|
||||||
meta = with pkgs.stdenv.lib.maintainers; {
|
meta = with pkgs.stdenv.lib.maintainers; {
|
||||||
maintainers = [ bbigras ];
|
maintainers = [ bbigras i077 ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nodes = {
|
nodes = {
|
||||||
server =
|
server =
|
||||||
{ ... }:
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
services.restic.backups = {
|
services.restic.backups = {
|
||||||
remotebackup = {
|
remotebackup = {
|
||||||
inherit repository;
|
inherit repository passwordFile initialize paths pruneOpts;
|
||||||
passwordFile = "${passwordFile}";
|
};
|
||||||
initialize = true;
|
rclonebackup = {
|
||||||
paths = [ "/opt" ];
|
repository = rcloneRepository;
|
||||||
pruneOpts = [
|
rcloneConfig = {
|
||||||
"--keep-daily 2"
|
type = "local";
|
||||||
"--keep-weekly 1"
|
one_file_system = true;
|
||||||
"--keep-monthly 1"
|
};
|
||||||
"--keep-yearly 99"
|
|
||||||
];
|
# This gets overridden by rcloneConfig.type
|
||||||
|
rcloneConfigFile = pkgs.writeText "rclone.conf" ''
|
||||||
|
[local]
|
||||||
|
type=ftp
|
||||||
|
'';
|
||||||
|
inherit passwordFile initialize paths pruneOpts;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
environment.sessionVariables.RCLONE_CONFIG_LOCAL_TYPE = "local";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -38,25 +55,35 @@ import ./make-test-python.nix (
|
||||||
server.start()
|
server.start()
|
||||||
server.wait_for_unit("dbus.socket")
|
server.wait_for_unit("dbus.socket")
|
||||||
server.fail(
|
server.fail(
|
||||||
"${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots"
|
"${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots",
|
||||||
|
"${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots",
|
||||||
)
|
)
|
||||||
server.succeed(
|
server.succeed(
|
||||||
"mkdir -p /opt",
|
"mkdir -p /opt",
|
||||||
"touch /opt/some_file",
|
"touch /opt/some_file",
|
||||||
|
"mkdir -p /tmp/restic-rclone-backup",
|
||||||
"timedatectl set-time '2016-12-13 13:45'",
|
"timedatectl set-time '2016-12-13 13:45'",
|
||||||
"systemctl start restic-backups-remotebackup.service",
|
"systemctl start restic-backups-remotebackup.service",
|
||||||
|
"systemctl start restic-backups-rclonebackup.service",
|
||||||
'${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
|
'${pkgs.restic}/bin/restic -r ${repository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
|
||||||
|
'${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^1 snapshot"',
|
||||||
"timedatectl set-time '2017-12-13 13:45'",
|
"timedatectl set-time '2017-12-13 13:45'",
|
||||||
"systemctl start restic-backups-remotebackup.service",
|
"systemctl start restic-backups-remotebackup.service",
|
||||||
|
"systemctl start restic-backups-rclonebackup.service",
|
||||||
"timedatectl set-time '2018-12-13 13:45'",
|
"timedatectl set-time '2018-12-13 13:45'",
|
||||||
"systemctl start restic-backups-remotebackup.service",
|
"systemctl start restic-backups-remotebackup.service",
|
||||||
|
"systemctl start restic-backups-rclonebackup.service",
|
||||||
"timedatectl set-time '2018-12-14 13:45'",
|
"timedatectl set-time '2018-12-14 13:45'",
|
||||||
"systemctl start restic-backups-remotebackup.service",
|
"systemctl start restic-backups-remotebackup.service",
|
||||||
|
"systemctl start restic-backups-rclonebackup.service",
|
||||||
"timedatectl set-time '2018-12-15 13:45'",
|
"timedatectl set-time '2018-12-15 13:45'",
|
||||||
"systemctl start restic-backups-remotebackup.service",
|
"systemctl start restic-backups-remotebackup.service",
|
||||||
|
"systemctl start restic-backups-rclonebackup.service",
|
||||||
"timedatectl set-time '2018-12-16 13:45'",
|
"timedatectl set-time '2018-12-16 13:45'",
|
||||||
"systemctl start restic-backups-remotebackup.service",
|
"systemctl start restic-backups-remotebackup.service",
|
||||||
|
"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 ${repository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
|
||||||
|
'${pkgs.restic}/bin/restic -r ${rcloneRepository} -p ${passwordFile} snapshots -c | grep -e "^4 snapshot"',
|
||||||
)
|
)
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue