-   Linux - Desktop (
-   -   an rsync question (

phantom630 01-15-2011 08:59 AM

an rsync question
hello all,

i am using rsync to backup my shell scripts for some time. i just checked the backup destinations and noticed that deleted files at the source still exist at the destination.

my rsync command is;

rsync -avz --delete --recursive /home/user/*sh /backup
i created a dummy .sh file, backed it up by the above command, then deleted it and re-run the command. rsync does not delete the dummy .sh file at the destination!

obviously i am doing something wrong, can you please help me find it?

fordeck 01-15-2011 09:45 AM

I wonder if it could be a permissions issue. I tried running the same command only to another directory in my own home directory and it deletes the file as you would expect. You might check permissions for the user on /backup directory.



phantom630 01-15-2011 10:07 AM

thanks for your reply, fordeck.

i am running the command as root. unfortunately no permissions issue.

my OS is Ubuntu Lucid Lynx. very strange that your command runs proper, mine does not delete the originally deleted files :(

fordeck 01-15-2011 11:28 AM

Actually when I tried it I did not use a wildcard match (i.e. /home/user/*sh). In other words I just used:


rsync -avz --delete --recursive testing/ testing2/
The above worked, however when I did:


rsync -avz --delete --recursive testing/*sh testing2/
it would no longer delete files on the destination side.

The man page has the following section related to --delete:

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.


phantom630 01-15-2011 11:56 AM

hello fordeck,

yes the problem seems the wildcard pattern.

however, it is interesting that rsync being so versatile, i can not run it with a pseudo command like: synchronize all *sh files between source & destination directories, source being master and destination being slave.

rsync only performs file copy from source to destination when source is a wildcard pattern :confused:

i believe i am missing something with such a highly configurable program like rsync!


fordeck 01-16-2011 11:02 AM

Your right rsync being as configurable as it is should be able to do what you are asking. I believe this may be one way to accomplish your task, however you may want to add -n to do a dry run first:


rsync -avz --delete --include '*sh' --exclude '*' /home/user/ /backup/
I hope this helps,


phantom630 01-16-2011 07:04 PM

dear fordeck,

thank you for your support, now rsync works just the way i wanted!

i deployed the include & exclude filters. however, one should pay attention to adding character "/" to the end of source and destination dirs; since omitting / directs rsync in a wrong way.

hope this thread helps others messing with rsync :)


All times are GMT -5. The time now is 09:23 AM.