Rsync CentOS 7: Sync & Backup Files
Here are some common examples of rsync commands that can be used in CentOS7 for synchronizing and backing up files.
- Sync local folder to remote server.
 
rsync -avz /path/to/source/ username@remote.server:/path/to/destination/
- Sync files from remote server to local folder.
 
rsync -avz username@remote.server:/path/to/source/ /path/to/destination/
- Back up a local folder to another local folder.
 
rsync -avz /path/to/source/ /path/to/destination/
- Incremental backup:
 
rsync -avz --backup --backup-dir=/path/to/backup/dir /path/to/source/ /path/to/destination/
- Synchronize folders while excluding certain files or folders.
 
rsync -avz --exclude='file.txt' /path/to/source/ /path/to/destination/
Here are some common examples of rsync commands that you can customize based on your needs. The meaning of the parameters in the rsync command is as follows:
- a: indicates archive mode, preserving file attributes and directory structure.
 - -v: indicates verbose mode, displaying the file synchronization process in detail.
 - -z: indicates compressing data for transmission.
 - -backup: indicates backup mode, preserving backup versions of the source files.
 - – Specify the directory for storing backup files with the option “backup-dir.”
 - – exclude: exclude specified files or folders
 
To learn more about the parameters and usage of the rsync command, you can enter “man rsync” in the terminal to view the help documentation.