summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-04-17 03:51:55 +0200
committertv <tv@krebsco.de>2016-04-17 03:51:55 +0200
commit453384b60b628f97074c74940e88570aa8eab811 (patch)
tree41126f0e7eca1419f13a23e346758d1d57554944 /krebs
parent904d037bd704d9690b8a9a8e8338950931e3ccd1 (diff)
krebs.backup: inject dst_path into dst shell
Diffstat (limited to 'krebs')
-rw-r--r--krebs/3modules/backup.nix27
1 files changed, 13 insertions, 14 deletions
diff --git a/krebs/3modules/backup.nix b/krebs/3modules/backup.nix
index 1cd851a4e..1e926429a 100644
--- a/krebs/3modules/backup.nix
+++ b/krebs/3modules/backup.nix
@@ -163,41 +163,40 @@ let
"$src/" \
"$dst/.partial"
dst_exec env \
+ dst_path="$dst_path" \
start_date="$start_date" \
flock -n "$dst_path" \
/bin/sh < ${toFile "backup.${plan.name}.take-snapshots" ''
set -efu
- : $start_date
+ : $dst_path $start_date
- dst=${shell.escape plan.dst.path}
-
- mv "$dst/current" "$dst/.previous"
- mv "$dst/.partial" "$dst/current"
- rm -fR "$dst/.previous"
+ mv "$dst_path/current" "$dst_path/.previous"
+ mv "$dst_path/.partial" "$dst_path/current"
+ rm -fR "$dst_path/.previous"
echo >&2
snapshot() {(
: $ns $format $retain
name=$(date --date="@$start_date" +"$format")
- if ! test -e "$dst/$ns/$name"; then
+ if ! test -e "$dst_path/$ns/$name"; then
echo >&2 "create snapshot: $ns/$name"
- mkdir -m 0700 -p "$dst/$ns"
+ mkdir -m 0700 -p "$dst_path/$ns"
rsync >&2 \
-aAXF --delete \
- --link-dest="$dst/current" \
- "$dst/current/" \
- "$dst/$ns/.partial.$name"
- mv "$dst/$ns/.partial.$name" "$dst/$ns/$name"
+ --link-dest="$dst_path/current" \
+ "$dst_path/current/" \
+ "$dst_path/$ns/.partial.$name"
+ mv "$dst_path/$ns/.partial.$name" "$dst_path/$ns/$name"
echo >&2
fi
case $retain in
([0-9]*)
delete_from=$(($retain + 1))
- ls -r "$dst/$ns" \
+ ls -r "$dst_path/$ns" \
| sed -n "$delete_from,\$p" \
| while read old_name; do
echo >&2 "delete snapshot: $ns/$old_name"
- rm -fR "$dst/$ns/$old_name"
+ rm -fR "$dst_path/$ns/$old_name"
done
;;
(ALL)