]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
bin/srsync-incremental: Try to remove current/ if backup failed.
authorSimon Ruderich <simon@ruderich.org>
Sat, 7 Dec 2013 20:37:21 +0000 (21:37 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sat, 7 Dec 2013 20:37:21 +0000 (21:37 +0100)
bin/srsync-incremental

index 16aa88a0215f3db4cb4d231bc212bbf3bd783135..644b2fef253f9a881026b3afa1fbc4f3b968b2b5 100755 (executable)
@@ -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"