1

How can I list deleted files and between which increments this happened?

I wrote a clumsy and slow shell script but I think there must be a better way:

#!/bin/bash -e

# helper tool für rdiff-backup
# see https://serverfault.com/questions/983941/list-deleted-files-from-rdiff-backup

inc_dates=($(rdiff-backup --list-increments "$1" | tail -n+2 | head -n-1 | cut -d "." -f2))
total=${#inc_dates[*]}

for (( i=0; i<$(( $total )); i++ ))
do
  tmplist[$i]=$(tempfile);
  rdiff-backup --list-at-time "${inc_dates[$i]}" "$1" | sort > "${tmplist[$i]}"
  if [ "$i" -gt 0 ]; then
    deleted=($(comm -2 -3 "${tmplist[$i-1]}" "${tmplist[$i]}"))

    nr=${#deleted[*]}

    if [ "$nr" -gt 0 ]; then
      echo "$nr file(s) deleted between ${inc_dates[$i-1]} and ${inc_dates[$i]}:"
      printf '%s\n' "${deleted[@]}"
    fi

  fi
done

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.