CLOUD
Guides

Automatic Backup Setup: A Complete Guide

CLOUD|March 4, 2026|4 min read|385 views
Automatic Backup Setup: A Complete Guide

No backup = just a matter of time before you lose data. 3 methods: cron + rsync, duplicity, and backup to object storage.

Why Automatic Backup, Not Manual

Manual backup fails for one simple reason: humans forget. Studies show that 60% of companies relying on manual backup lose data within the first two years. Automatic backup removes the human factor from the equation and ensures continuous data protection without intervention.

The difference between having a backup and not having one is the difference between hours of downtime and months of downtime. Or between limited loss and complete shutdown.

Types of Backup

Before setting up the system, understand the available types:

Full Backup

A complete copy of all data every time. The simplest, slowest, and most storage-intensive.

  • Advantages: Fast and straightforward restoration
  • Disadvantages: Consumes large storage and takes a long time
  • Best use: Weekly or monthly backup

Incremental Backup

Copies only files that changed since the last backup (full or incremental). The fastest and least storage-intensive.

  • Advantages: High speed and less storage
  • Disadvantages: Restoration requires all incremental backups in order
  • Best use: Daily backups

Differential Backup

Copies all files that changed since the last full backup. A compromise between full and incremental.

  • Advantages: Faster restoration than incremental
  • Disadvantages: Grows larger each day until the next full backup
  • Best use: Daily backups with weekly full backup

Setting Up Automatic Backup on Linux

Step 1: Configure rsync with cron

rsync is the standard backup tool on Linux. Fast, reliable, and transfers only changes:

#!/bin/bash
# backup.sh
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
SOURCE="/var/www/"
DEST="/backup/$TIMESTAMP/"
LOG="/var/log/backup.log"

rsync -avz --delete $SOURCE $DEST >> $LOG 2>&1

if [ $? -eq 0 ]; then
 echo "[$TIMESTAMP] Backup completed successfully" >> $LOG
else
 echo "[$TIMESTAMP] Backup FAILED" >> $LOG
fi

Step 2: Schedule the Task in cron

# Daily backup at 2 AM
0 2 * * * /root/scripts/backup.sh

# Full backup every Sunday at 3 AM
0 3 * * 0 /root/scripts/full-backup.sh

Step 3: Rotate Old Backups

Do not let backups accumulate until storage is full:

# Delete backups older than 30 days
find /backup/ -type d -mtime +30 -exec rm -rf {} +

Setting Up Database Backup

MySQL / MariaDB

#!/bin/bash
TIMESTAMP=$(date +%Y%m%d)
mysqldump --all-databases --single-transaction \
 --routines --triggers \
 | gzip > /backup/db/all-databases-$TIMESTAMP.sql.gz

PostgreSQL

#!/bin/bash
TIMESTAMP=$(date +%Y%m%d)
pg_dumpall | gzip > /backup/db/pg-all-$TIMESTAMP.sql.gz

Off-Server Backup

A backup on the same server does not protect you from hardware failure. You need an external copy:

Method Advantages Disadvantages
Second server via rsync+SSH Full control, low cost Requires manual management
Object Storage High flexibility, unlimited space Variable cost
Managed backup service No management, automatic encryption Higher cost

Setting Up Alerts

Backup without alerts means you will not know if it fails. Add alerts for every scenario:

# Send alert on backup failure
if [ $? -ne 0 ]; then
 curl -X POST https://hooks.example.com/alert \
 -d "message=Backup failed on $(hostname) at $(date)"
fi
Backup Type Frequency Retention Purpose
Incremental Hourly 24 hours Protection from human error
Daily incremental Daily 7 days Protection from corruption
Full Weekly 4 weeks Reliable restore point
Full Monthly 12 months Long-term archive

Backup with CLOUD

CLOUD provides managed backup service for cloud server clients: daily backup with 7-day retention for affordable pricing — pricing and plans per year, or 30-day retention for affordable pricing — pricing and plans per year. Managed cloud hosting clients receive daily, weekly, and monthly backup included free with every package.

Conclusion

Automatic backup is not a luxury. It is the last line of defense between your data and disaster. Set it up once correctly, test it regularly, and you will never need to worry again.


Get Started

Want to try it yourself? Choose the right hosting plan or build your custom server with the specs you need.

Share