[LUNI] fun with rsync

Ramin K ramin-list at badapple.net
Tue Jan 23 18:25:57 CST 2007


Later versions of rsync, ie 2.6.7 or better, have some nifty new 
functionality namely the --chmod flag.

Say you've got a large data share that has a number of applications 
writing all sorts of files to it with different permissions. Some dirs 
are -rw------- some are -rwx-r-x-r-x and so on. You're attempting to 
move to new storage and you'd like to clean these permissions up and fix 
assorted application while you're at it.

rsync -av --chmod=Fug+rw,Dug+rwx,Fo+r,Do+rx /src/ /dst/

The above command is processed in the following order and all that apply 
are applied.

Files:	 	user/group add read and write
Diretory:	user/group add read, write, execute
Files:		other add read
Directory:	other add read and execute

--chmod only works when you use -p (--perms) which is implied in the -av 
commands. Redhat 4 based distros will have to upgrade as it ships with 
2.6.3 which does not have this functionality.

Ramin


More information about the luni mailing list