lol

nixos: tarsnap - separate archive cachedirs

Tarsnap locks the cachedir during backup, meaning if you specify
multiple backups with a shared cache that might overlap (for example,
one backup may take an hour), secondary backups will fail. This isn't
very nice behavior for the obvious reasons.

This splits the cache dirs for each archive appropriately. Note that
this will require a rebuild of your archive caches (although if you were
only using one archive for your whole system, you can just move the
directory).

Signed-off-by: Austin Seipp <aseipp@pobox.com>

+10 -3
+10 -3
nixos/modules/services/backup/tarsnap.nix
··· 5 5 let 6 6 cfg = config.services.tarsnap; 7 7 8 - configFile = cfg: '' 9 - cachedir ${config.services.tarsnap.cachedir} 8 + configFile = name: cfg: '' 9 + cachedir ${config.services.tarsnap.cachedir}/${name} 10 10 keyfile ${config.services.tarsnap.keyfile} 11 11 ${optionalString cfg.nodump "nodump"} 12 12 ${optionalString cfg.printStats "print-stats"} ··· 56 56 Should the cache become desynchronized or corrupted, tarsnap 57 57 will refuse to run until you manually rebuild the cache with 58 58 <command>tarsnap --fsck</command>. 59 + 60 + Note that each individual archive (specified below) has its own cache 61 + directory specified under <literal>cachedir</literal>; this is because 62 + tarsnap locks the cache during backups, meaning multiple services 63 + archives cannot be backed up concurrently or overlap with a shared 64 + cache. 59 65 60 66 Set to <literal>null</literal> to disable caching. 61 67 ''; ··· 258 264 mkdir -p -m 0700 ${cfg.cachedir} 259 265 chown root:root ${cfg.cachedir} 260 266 chmod 0700 ${cfg.cachedir} 267 + mkdir -p -m 0700 ${cfg.cachedir}/$1 261 268 DIRS=`cat /etc/tarsnap/$1.dirs` 262 269 exec tarsnap --configfile /etc/tarsnap/$1.conf -c -f $1-$(date +"%Y%m%d%H%M%S") $DIRS 263 270 ''; ··· 280 287 281 288 environment.etc = 282 289 (mapAttrs' (name: cfg: nameValuePair "tarsnap/${name}.conf" 283 - { text = configFile cfg; 290 + { text = configFile name cfg; 284 291 }) cfg.archives) // 285 292 (mapAttrs' (name: cfg: nameValuePair "tarsnap/${name}.dirs" 286 293 { text = concatStringsSep " " cfg.directories;