In this post, we’ll explore Rsync file transfer, including how it works, its key options, and how to set it up for fast and secure local and remote syncing on Linux systems.
Rsync is a file transfer tool which is widely use to transfer data from local disk to Over Internet. The service use Port 22, (873 with rsync daemon) to transfer data and manage complexity to sync data and their permissions/ownerships. It transfer the files which are newly updated using checksum checks and update those parts of files which are updated in source server which save bandwidth of server.
How Rsync File Transfer Works
Rsync use tcp protocol to transmit data from one server to another server and it makes easy to sync data with the metadata and permissions of file. It use checksum feature which validate file changes and change sync file content with source server.
The message sending incremental file list
can sent the list of files and directories which are going to sync to remote server after sending incremental file list, the rsync check checksum value for both source and destination server to verify changes, once changes validation successfully done the file which has different checksum value got sync to destination with files current permissions, ownerships and timestamp.
Rsync File Transfer Flags and Options:
Flags | Use-cases |
-a | Archive mode which preserves permissions, symlinks, timestamps, recursive. |
-p | Preserve Permissions. |
-o | Preserve Ownership. |
-g | Preserve Groups. |
-t | Preserve File Modified time. |
-l | Preserve Symlinks as a symlink |
-H | Preserve Hard links. |
-A | Preserve ACL Permissions. |
-X | Preserve extended attributes. |
-v | Vorbose the output. |
-P or –progress | Show current progress of transfer. |
–bwlimit | Limit the speed of transfer (Saves Bandwidth). |
–delete | Delete extra files in destination. |
–remove-source-files | Remove files from source path. |
Installing Rsync for File Transfer:
# On RHEL/CentOS/Rocky Linux
yum install rsync -y
# On Debian/Ubuntu
apt-get install rsync -y
# On macOS (with Homebrew)
brew install rsync
Local and Remote Rsync File Transfers:
The basic file transfer sample using rsync.
Local Transfer:
[root@linuxhardened ~]# rsync -av test.txt /tmp
Normal sync with just sync data without any rule or permission
Remote Transfer:
Their are 2 types of file transfer in remote transfer methode. Either use 22 port for secure connection or use 873 port by rsync daemon to bulk transfer makes easy to push or pull data.
Secure Way using Port 22:
[root@linuxhardened ~]# rsync -avz /data/ user@remote.com:/backup/
Daemon way using 873:
[root@linuxhardened ~]# rsync -avz /data/ remote.com::FLAG/backup/
OR
[root@linuxhardened ~]# rsync -avz remote.com::FLAG/backup/ /data/
Best Practices for Rsync File Transfer:
One of the most important practices when using rsync is to test your command with the --dry-run
option before executing it for real. This allows you to preview which files will be transferred, deleted, or modified without making any actual changes.
Commands like --remove-source-files
or --delete
can cause permanent data loss if used incorrectly. For example, if you accidentally run rsync on a critical directory such as /etc
with --remove-source-files
, the original configuration files will be removed from the source system. Since those files are essential for services to run, the system may fail to function, and retrieving them from the destination could become impossible.
Configuring Rsync Daemon for File Transfer:
Download and install daemon for rsync.
[root@remote ~]# yum install rsync-daemon.noarch -y
Enable and start daemon service:
[root@remote ~]# systemctl enable --now rsyncd
Edit conf file and add require flags:
[root@remote ~]# cat >> /etc/rsyncd.conf <<EOF
[repobackps]
path = /
use chroot = no
max connections = 50
hosts allow = 192.168.0.0/16
uid = root
gid = root
read only = no
EOF
After adding above line restart rsyncd.service
[root@linuxhardened ~]# systemctl restart rsyncd
Why Use Rsync Daemon?
It helps to operate incremental Linux backup with rsync and manage their permissions, ownerships, checksum’s, selinux permissions, ACL’s Special Permissions etc.
It make ease to manage backups automatically using Cron schedules and doesn’t require root or sudo access to sync data.
In upcoming posts, we’ll dive deep into Rsync flags and arguments — showing you how to use them effectively for faster, safer, and smarter file syncs.
In the upcoming chapter, We will explore Rsync flags and arguments, with real-world examples.