Rsync 2.5.7 --delete and --backup behavoir

Matt McCutchen hashproduct+rsync at gmail.com
Sat Dec 9 18:31:24 GMT 2006


On 12/7/06, Grok Mogger <linuximp at gmail.com> wrote:
> Is there any way to include deleted empty folders in the backup?

No, rsync does not support backing up folders.  Do you need to back up
the attributes of the deleted folders?  If not, you could just write a
script to create backup folders of the same names as the folders rsync
says it deleted.  Try something like this in bash:

rsync --itemize-changes <...> | (
    while IFS='' read line; do
        if [[ "$line" =~ '^\*deleting (.*)/$' ]]; then
            mkdir backupdir/"${BASH_REMATCH[1]}"
        fi
    done
)

If you do need the attributes, one possibility is to run rsync in
dry-run mode to get a list of the folders it wants to delete, back
them up while they still exist so you can preserve their attributes,
and then run rsync for real.

Matt


More information about the rsync mailing list