From 8935e6db7519655d39889a85a6c72edf4a9ee333 Mon Sep 17 00:00:00 2001 From: Simon Ruderich Date: Sat, 7 Dec 2013 21:37:21 +0100 Subject: [PATCH] bin/srsync-incremental: Try to remove current/ if backup failed. --- bin/srsync-incremental | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bin/srsync-incremental b/bin/srsync-incremental index 16aa88a..644b2fe 100755 --- a/bin/srsync-incremental +++ b/bin/srsync-incremental @@ -53,4 +53,12 @@ rsync \ --archive --hard-links --numeric-ids --one-file-system \ --link-dest="$dest" \ "$@" current \ -&& mv current "$target" +|| { + # Try to remove "current" without changing the exit code. In case the + # connection failed without transferring any files, we want the next + # backup to be able to run. + code=$? + rmdir current 2>/dev/null || true + exit $code +} +mv current "$target" -- 2.45.2