Hi!
I’m trying to run a scheduled borgbackup job on a LUKS encrypted removable HDD. The HDD is a dedicated backup drive, so I want to mount it in the preHook
and unmount it in the postHook
.
However, when the service runs, it fails with the error message:
borgbackup-job-testBackup.service: Failed to set up mount namespacing: /data/backup/testBackup: No such file or directory
borgbackup-job-testBackup.service: Failed at step NAMESPACE spawning /nix/store/ra2sr1y6fy6gjr63bglql0r594g8qxca-unit-script-borgbackup-job-tes>
Everything runs fine when I manually mount the HDD, but I was hoping that the prehook would do that for me (as it is actually stated in the documentation: that’s what it’s for).
Here’s the testConfig I’m using (the repository is pre-initialized, since the creation is buggy with nix):
services.borgbackup = {
jobs.testBackup = {
privateTmp = false;
preHook = with pkgs; /*bash*/ ''
echo "Starting the prehook"
${cryptsetup}/bin/cryptsetup open /dev/sde1 backupDrive --key-file=/etc/secrets/backupKeyfile.key
${mount}/bin/mount --mkdir /dev/mapper/backupDrive /data/backup
'';
postHook = with pkgs; /*bash*/ ''
${umount}/bin/umount /data/backup
${cryptsetup}/bin/cryptsetup close /dev/mapper/backupDrive
'';
startAt = "*-*-* *:*:*5";
prune.keep = {
within = "1d";
};
removableDevice = true;
doInit = true;
compression = "auto,lzma";
encryption.mode = "none";
inhibitsSleep = true;
repo = "/data/backup/testBackup";
paths = [
"/tmp/testbackup"
];
readWritePaths = [
"/tmp/testbackup"
];
};
};