rsync --delete does not work as expected

Willem

New Member
Credits
0
Dear all

I'm using rsync to keep a backup of certain directories on my backup server.

I notice the following rsync command works, and place a folder called "zipped" inside the "/backup/" directory and deletes removed files on the source:
rsync -vrptgolz --progress --stats --delete [email protected]_server:/remote_backup/zipped /backup/

The following rsync command copies the files over, but do not delete removed files on the source:
rsync -vrptgolz --progress --stats --delete [email protected]_server:/remote_backup/zipped/* /backup/zipped/

Does anyone know why the 2nd command does not delete removed files on the source as expected?

Kind Regards,
 


atanere

Well-Known Member
Credits
0
Hi @Willem, and welcome. I'm far from an expert with rsync, but in your first example, you are copying the "zipped" folder, as you said. In your second example, you are trying to copy the files loosely, without taking the "zipped" folder with it (because you have already created the folder in the destination).

What I would try to do is use your second example exactly as you have it, except.... remove the * character. Leave the source "zipped" with the / character (so, zipped/ and not zipped/*) and that will also copy the contents loosely. I hope that works!

[EDIT] I think this explains it, from the rsync man page (bold is mine):

--delete
This tells rsync to delete extraneous files from the receiving
side (ones that aren’t on the sending side), but only for the
directories that are being synchronized. You must have asked
rsync to send the whole directory (e.g. "dir" or "dir/") without
using a wildcard for the directory’s contents (e.g. "dir/*")

since the wildcard is expanded by the shell and rsync thus gets
a request to transfer individual files, not the files’ parent
directory.

Cheers
 
Last edited:


Members online


Latest posts

Top