Parent directory permissions changed when transferring contents.

jlmunn jlmunn at micron.com
Wed Mar 19 04:33:06 EST 2003


I have a script that checks files out of PVCS into a temp directory (possibly with nested directories) and copies the contents of the temp directory to multiple servers. I want to retain the permissions on the individual files (which are retained in source control) but leave the permissions on the destination directories as they are. The temp directory and it's subdirectories get the default permissions of a new directory when they are created, which I don't want to copy to my production directories. I am assuming at this point that I will have to rsync each directory separately to accomplish this.

The problem I am having is copying the contents of a directory without modifying the permissions of the actual directory. I have tried several various commands including:

rsync -avz ~me/source/ ~me/dest/
rsync -avz ~me/source/ ~me/dest/ --exclude=/*/

The man page says:

	A trailing  /  on  a  source  name means  "copy  the  contents  of  
      this directory".  Without a trailing slash it means "copy the directory".

but both of these also update the permissions of the dest directory to those of the source directory. I've tried other excludes (/./, ./) but cannot keep rsync from modifying the dest directory permission.

rsync -lptg ~me/source/* ~me/dest/

does almost what I want, it copies just the files, with permissions, and doesn't change the permissions on the dest directory, but it doesn't copy hidden files. The only way I've found to get all the files this way is with two calls to rsync:

rsync -lptg ~me/source/* ~me/dest/
rsync -lptg ~me/source/.* ~me/dest/

I would like to avoid two calls for each directory if possible.

Is there a way with the first, trailing slash, syntax to avoid copying the permissions of the parent directory? If not, is there another way to copy all files (including hidden files) with only one rsync call?

Thanks,

Jim Munn


More information about the rsync mailing list