@@ -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;