How to Use Rsync to Create a Backup on CentOS 8
In this tutorial, we will use Rsync to create a backup on CentOS 8. Backups will be sent to the second server and stored there. So we need 2 working and configured CentOS 8 servers.
Installing Rsync packages
Let's check if the necessary Rsync packages are installed and install them if not.
Start the Rsync daemon and enable its automatic starting.
Check if auto start is enabled and working.
● rsyncd.service - fast remote file copy program daemon
Loaded: loaded (/usr/lib/systemd/system/rsyncd.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2020-12-19 13:18:16 UTC; 6s ago
...
Check if the Rsync service is listening on the network port.
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 55746/rsync
tcp6 0 0 :::873 :::* LISTEN 55746/rsync
Configuring the backup source server
Open the configuration file:
Insert following lines in it:
pid file = /var/run/rsyncd.pid
# User name and group for reading source files
uid = rsync-user
gid = rsync-user
# Do not allow to modify the source files
read only = yes
# Data Source Configuration
[data]
path = /home/user
list = yes
auth users = rsync-user
secrets file = /etc/secret.passwd
Create a file with credentials for authorization on this machine.
Enter username and password in it.
Change the file permissions to read-only by the root user.
Restart the Rsync daemon.
You also need to create the user that was specified in the configuration and file with credentials.
Сonfiguring the receiving Rsync backup server
Create a file for the password.
Enter the password for the Rsync user on the source server.
Change its permissions here as well.
Running a backup
Create a folder for backup.
The following command will start the backup. Replace source-server-ip with the source server's IP address.