Copy new files from source to target and skip files if it already exist in target
rsync --dry-run -avzurh --stats --delete --progress /tmp/source/ /tmp/target/
-a
-> Archive mode, preserve the file system properties-v
-> Verbose output-z
-> Use compression mode for data transfer, speeds up for transfer over network-h
-> Output in human readable format-u
-> Skip if a file already exist in target directory, makes it efficient to copy only the missing files in target directory. Without this flag, it will overwrite the file in the target directory-r
-> recursive mode, copies subdirectory--delete
-> delete the additional files or directories which are present in target directory which are not present in source directory--dry-run
-> do a dry run without making any changes to the file system--stats
-> give the stats at the end of the process--progress
-> show progress while copying the files
Copy the source directory itself into the target directory (missing trailing slash at the end)
rsync -avzurh /tmp/source /tmp/target
Copy from local source directory to remote directory
rsync -avzurh /tmp/source/ [email protected]:/tmp/remote-target/
Copy from remote source directory to local target directory
rsync -avzurh [email protected]:/tmp/remote-source/ /tmp/target/
Copy from remote source directory to remote target directory
rsync -avzurh [email protected]:/tmp/remote-source/ [email protected]:/tmp/remote-target/
Copies all files except logs
rsync -avzurh --exclude '*.log' /tmp/source/ /tmp/target/
Copies all files except logs files, but includes only important logs
rsync -avzurh --include '*important*.log' --exclude '*.log' /tmp/source/ /tmp/target/