git.iko.soy/typeable/nixpkgs
on master help sign in
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>

commit5f0253ace683bae4c7989f4db167676dd0a507e7 authorAustin Seipp <aseipp@pobox.com> dateThu 7 Jan 2016, 04:23 (11 years ago) parent78096e9
1 file changed+10−3
nixos/modules/services/backup/tarsnap.nix+10−3
nixos/modules/services/backup/tarsnap.nix+10−3
@@ -5,8 +5,8 @@ with lib;
55let
66 cfg = config.services.tarsnap;
77
8− configFile = cfg: ''
9− cachedir ${config.services.tarsnap.cachedir}
8+ configFile = name: cfg: ''
9+ cachedir ${config.services.tarsnap.cachedir}/${name}
1010 keyfile ${config.services.tarsnap.keyfile}
1111 ${optionalString cfg.nodump "nodump"}
1212 ${optionalString cfg.printStats "print-stats"}
@@ -57,6 +57,12 @@ in
5757 will refuse to run until you manually rebuild the cache with
5858 <command>tarsnap --fsck</command>.
5959
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.
65+
6066 Set to <literal>null</literal> to disable caching.
6167 '';
6268 };
@@ -251,6 +257,7 @@ in
251257 mkdir -p -m 0700 ${cfg.cachedir}
252258 chown root:root ${cfg.cachedir}
253259 chmod 0700 ${cfg.cachedir}
260+ mkdir -p -m 0700 ${cfg.cachedir}/$1
254261 DIRS=`cat /etc/tarsnap/$1.dirs`
255262 exec tarsnap --configfile /etc/tarsnap/$1.conf -c -f $1-$(date +"%Y%m%d%H%M%S") $DIRS
256263 '';
@@ -269,7 +276,7 @@ in
269276
270277 environment.etc =
271278 (mapAttrs' (name: cfg: nameValuePair "tarsnap/${name}.conf"
272− { text = configFile cfg;
279+ { text = configFile name cfg;
273280 }) cfg.archives) //
274281 (mapAttrs' (name: cfg: nameValuePair "tarsnap/${name}.dirs"
275282 { text = concatStringsSep " " cfg.directories;