just a logo :)

search:



imprint







sync directories
Entry Nr. 3191, by user 1
rsync -av --delete source/ destination/

This will sync the existing directory destination/ with the existing directory source/.

In contrast to cp -r this will also copy files starting with a dot like .htaccess.

Both slashes are important. Otherwise crazy shit will happen.

Before you really do it, run it with the -n option, which will do a simulation of the actual command and tell you what it would do:

rsync -avn --delete source/ destination/

The -a option is a sortcut for several options. If the above doesn't work for your specific usecase, you will have to finetune with the myriad of options rsync provides. I often use this one:

rsync -iOrtvcLkKn --delete source/ destination/

The parameters are:

-i output a change-summary for all updates
-O ommits directory times
-r recursive
-t preserve times
-v verbose
-c detect differences based on checksum, not on times
-L transform symlink into referent file/dir
-k transform symlink to dir into referent dir
-K treat symlinked dir on receiver as dir
-n dry run (simulate only)
--delete deletes files not present in source/ but present in destination/