DEV Community

Cover image for Backup and File Protection in Red Hat Linux
shamain anjum
shamain anjum

Posted on

Backup and File Protection in Red Hat Linux

Welcome to Day 22 of the 30 Days of Linux Challenge!

Today I explored the essentials of backup and file protection — a critical skill for system administrators, DevOps engineers, and even developers managing their own environments.

Whether it's user data, server configs, or logs — backups help recover from mistakes, failures, and cyber threats.

📚 Table of Contents

Why Backups Matter

Backups protect you from:

  • Human error (rm -rf, accidental overwrites)
  • System crashes and hardware failure
  • Misconfigurations or security breaches

If you're managing anything important — you need a backup plan.

Core Linux Backup Tools

Tool Use Case
cp Simple file copy
tar Archive and compress folders
rsync Sync files (local or remote)
cron Schedule automated backups

Backup Using tar

Backup /etc directory

sudo tar -czvf etc-backup-$(date +%F).tar.gz /etc

Image description

Flags:

-c: create

-z: compress (gzip)

-v: verbose

-f: filename

To extract:

tar -xzvf etc-backup-2024-04-30.tar.gz -C /restore/path

Sync Files with rsync

Basic usage:

rsync -avh /etc/ /backups/etc/

Image description

Remote sync over SSH:

rsync -az /var/www/ user@backupserver:/data/web_backup/

Flags:

-a: archive mode (preserves permissions)

-v: verbose

-h: human-readable

Schedule Backups with cron

Open crontab:
crontab -e

Run backup every day at 2 AM:

0 2 * * * /usr/bin/rsync -az /home /backups/home

List jobs:

crontab -l

Store and Protect Backups

🔐 Storage options:

  • Secondary disk
  • External drive
  • Offsite/Cloud (rsync.net, S3, etc.)

🔐 Protect with encryption:

gpg -c mybackup.tar.gz

Or using openssl:

openssl enc -aes-256-cbc -in backup.tar.gz -out backup.enc

Try It Yourself

Create a backup of /etc
sudo tar -czvf etc-$(date +%F).tar.gz /etc

Sync /home to backup drive
rsync -avh /home/ /mnt/backup/home/

Schedule a daily sync with cron
crontab -e

-Add: 0 3 * * * rsync -az /etc /backups/etc

Find the 5 largest folders
du -h / --max-depth=2 | sort -hr | head -n 5

Real-World Backup Patterns

Task Tool Used
Backup system configs tar, cron
Sync user files rsync, cp
Automate daily backups cron, rsync
Restore backups tar, cp, rsync
Encrypt sensitive archives gpg, openssl

Why This Matters

Linux is powerful — but not immune to failure.

With a smart backup strategy, you can:

  • Protect critical systems
  • Respond quickly to accidents
  • Sleep better knowing your data is safe
  • Even a simple weekly tar archive can be a lifesaver.

Top comments (0)