Incremental backup and empty dirs

Matt McCutchen hashproduct+rsync at
Tue May 1 21:08:44 GMT 2007

On 4/30/07, Mark <rsync at> wrote:
> Hi,
> I use rsync with such options:
> OPTIONS="-a -u -z -v -S --delete-during --ignore-errors \
>          -b --backup-dir=${PATH_BACKUP}/${DATE_YESTERDAY} \
>          --exclude-from=$IGNORE"
> rsync $OPTIONS ${PATH_SRC} \
>       ${PATH_BACKUP}/current
> Everything works as it should be, deleted files are transfered everyday
> to a new catalog, determinated by a variable ${DATE_YESTERDAY}.
> But if an empty dir is deleted from ${PATH_SRC}, then it is
> accordingly deleted from ${PATH_BACKUP}/current, and don`t appear in
> Do you know what to do it to make empty dirs be transferred

You could use an extra pass at the beginning to back up all dirs about
to be deleted, whether they are empty or not:

rsync -ni ${OPTIONS} ${PATH_SRC} ${PATH_BACKUP}/current \
    | sed -rne 's#^\*deleting (.*)/$#\1#p' \
    | rsync --out-format='backing up %n' --files-from=- \


More information about the rsync mailing list