From: Simon Ruderich Date: Sat, 7 Dec 2013 20:37:21 +0000 (+0100) Subject: bin/srsync-incremental: Try to remove current/ if backup failed. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=8935e6db7519655d39889a85a6c72edf4a9ee333;p=config%2Fdotfiles.git bin/srsync-incremental: Try to remove current/ if backup failed. --- 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"