DEV Community

Cover image for Centralized Backup Server with rsync and cron on Red Hat Linux
shamain anjum
shamain anjum

Posted on

Centralized Backup Server with rsync and cron on Red Hat Linux

Today’s project is both practical and RHCSA-aligned: setting up a secure, automated backup server using rsync over SSH and scheduled jobs with cron.

This is a real-world admin task and also mirrors RHCSA exam scenarios where backup automation and file transfer are common.

🔧 Objective

  • Use rsync to transfer files securely over SSH
  • Automate regular backups with cron
  • Secure access using SSH keys
  • Harden access with firewall and permissions

📚 RHCSA Skills Covered

✔ User and permission management

✔ SSH key authentication

✔ Automating jobs with cron

✔ File transfer with rsync

✔ Firewall configuration

1️⃣ Install rsync

sudo dnf install -y rsync

Check version:
rsync --version

Image description

2️⃣ Set Up SSH Key Authentication

On client machine (sending data):

ssh-keygen -t rsa

Image description

ssh-copy-id backupuser@backupserver

Now the client can connect without a password:

ssh backupuser@backupserver

Image description

3️⃣ Create a Backup Directory on the Server

sudo mkdir -p /backups/home
sudo chown backupuser:backupuser /backups/home

Image description

4️⃣ Test rsync Manually

From client to server:
rsync -avh /home/backupuser/Documents/
backupuser@backupserver:/backups/home/

Image description

Flags:

-a: archive mode (preserves permissions)
-v: verbose
-h: human-readable output

5️⃣ Automate Backups with cron

On the client:
crontab -e

Add this line to run backup every day at 2 AM:

0 2 * * * rsync -az /home/backupuser/Documents/ backupuser@backupserver:/backups/home/

Image description

Check your cron jobs:
crontab -l

Image description

6️⃣ Secure the Backup Server

Allow SSH and rsync port (default is SSH):
sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload

Image description

🧪 Try It Yourself

  • Schedule hourly or weekly backups
  • Add logging with rsync -avh --log-file=/var/log/backup.log
  • Create a backup rotation script (daily, weekly folders)
  • Test by restoring files from the server

✅ Recap

Task Tool/Command
Generate SSH keys ssh-keygen, ssh-copy-id
Create backup folder mkdir, chown
Transfer files securely rsync -avh source destination
Schedule backups crontab -e
Harden backup access firewalld, SSH key-only login

🎯 Why This Matters (RHCSA)

Backups are critical for disaster recovery.

This project tested:

  • SSH automation
  • Cron scheduling
  • Firewall management
  • Basic scripting and file system management
  • All of these are RHCSA core competencies.

Top comments (0)