0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 13:40:28 +03:00

nixos/borgbackup: fix extraArgs shell expansion (#332319)

This commit is contained in:
Guillaume Girol 2024-12-21 16:08:45 +01:00 committed by GitHub
commit d832d03b19
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 38 additions and 13 deletions

View file

@ -3,6 +3,8 @@ import ./make-test-python.nix ({ pkgs, ... }:
let
passphrase = "supersecret";
dataDir = "/ran:dom/data";
subDir = "not_anything_here";
excludedSubDirFile = "not_this_file_either";
excludeFile = "not_this_file";
keepFile = "important_file";
keepFileData = "important_data";
@ -69,6 +71,7 @@ in {
yearly = 5;
};
exclude = [ "*/${excludeFile}" ];
extraCreateArgs = [ "--exclude-caches" "--exclude-if-present" ".dont backup" ];
postHook = "echo post";
startAt = [ ]; # Do not run automatically
};
@ -166,8 +169,10 @@ in {
)
client.succeed("chmod 0600 /root/id_ed25519.appendOnly")
client.succeed("mkdir -p ${dataDir}")
client.succeed("mkdir -p ${dataDir}/${subDir}")
client.succeed("touch ${dataDir}/${excludeFile}")
client.succeed("touch '${dataDir}/${subDir}/.dont backup'")
client.succeed("touch ${dataDir}/${subDir}/${excludedSubDirFile}")
client.succeed("echo '${keepFileData}' > ${dataDir}/${keepFile}")
with subtest("local"):
@ -180,6 +185,10 @@ in {
client.fail(
"{} list '${localRepo}::${archiveName}' | grep -qF '${excludeFile}'".format(borg)
)
# Make sure excludedSubDirFile has been excluded
client.fail(
"{} list '${localRepo}::${archiveName}' | grep -qF '${subDir}/${excludedSubDirFile}".format(borg)
)
# Make sure keepFile has the correct content
client.succeed("{} extract '${localRepo}::${archiveName}'".format(borg))
assert "${keepFileData}" in client.succeed("cat ${dataDir}/${keepFile}")