From: Simon Ruderich Date: Thu, 22 Jun 2017 12:52:01 +0000 (+0200) Subject: bin/srsync-incremental: remove target directory if empty X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=0627246aa2b5db1320965061e517f65742be9d19;p=config%2Fdotfiles.git bin/srsync-incremental: remove target directory if empty --- diff --git a/bin/srsync-incremental b/bin/srsync-incremental index 9ade4e4..187e6b6 100755 --- a/bin/srsync-incremental +++ b/bin/srsync-incremental @@ -59,4 +59,8 @@ rsync \ rmdir "$target_tmp" 2>/dev/null || true exit $code } +# --dry-run (-n) creates an empty directory. Remove it to prevent using it for +# further incremental backups (which would do a full backup). +rmdir "$target_tmp" 2>/dev/null && exit 0 || true + mv "$target_tmp" "$target"