prevent trying to remove a backup dir already being deleted by another rsync instance
authorColas Nahaboo <colas@nahaboo.net>
Fri, 26 May 2017 10:04:48 +0200
changeset 17599c5671b789
parent 16 af10f983eb68
child 18 17013dda6719
prevent trying to remove a backup dir already being deleted by another rsync instance
rsync-incr
     1.1 --- a/rsync-incr	Tue May 23 13:49:32 2017 +0200
     1.2 +++ b/rsync-incr	Fri May 26 10:04:48 2017 +0200
     1.3 @@ -19,6 +19,7 @@
     1.4  export RSYNC_RSH="${RSYNC_RSH:-ssh}" # for 2.6.3, where ssh is the default
     1.5  EXT=past
     1.6  pbsm=10
     1.7 +export dellog=/tmp/rsync-incr-deletions.$LOGNAME
     1.8  
     1.9  #------------------------------------------------------------------ options
    1.10  option_n=0;snapshot=false;hardlinks="-H";do_gzip=false;global_remove=false
    1.11 @@ -49,7 +50,10 @@
    1.12  dfof () { df -mP "$1" |tail -1|awk '{print $4}'; }
    1.13  remdir () { 
    1.14    local empty=/tmp/empty-dir-for-rsync.$LOGNAME
    1.15 +  local path=$(realpath "$1")
    1.16    if test -n "$1"; then echo -n "Only $1 M free, "; fi
    1.17 +  fgrep -xq "$path" $dellog && return # is being deleted by another instance
    1.18 +  echo "$path" >>$dellog
    1.19    echo "Removing old backup: $2"
    1.20    # fast rm ,see https://unix.stackexchange.com/questions/106133/why-is-rm-slow
    1.21    mkdir -p $empty