Pricing Data Centers
Sign Up Client Portal Configure Server

Configuring Automated Backups

Last updated: March 19, 2026 Server Management

Backup Strategy Overview

A solid backup strategy follows the 3-2-1 rule: keep at least 3 copies of your data, on 2 different media, with 1 stored off-site. This guide shows you how to set up automated backups on your dedicated server.

Method 1: Automated Backups with rsync + cron

The simplest approach for file-level backups:

# Create backup script
sudo nano /usr/local/bin/backup.sh
#!/bin/bash
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/backup/$TIMESTAMP"
mkdir -p "$BACKUP_DIR"

# Backup important directories
rsync -a --delete /var/www/ "$BACKUP_DIR/www/"
rsync -a --delete /etc/ "$BACKUP_DIR/etc/"

# Backup databases
mysqldump --all-databases | gzip > "$BACKUP_DIR/mysql_all.sql.gz"

# Remove backups older than 30 days
find /backup -maxdepth 1 -type d -mtime +30 -exec rm -rf {} \;

echo "Backup completed: $BACKUP_DIR"
# Make executable and schedule
sudo chmod +x /usr/local/bin/backup.sh
sudo crontab -e
# Add: 0 3 * * * /usr/local/bin/backup.sh >> /var/log/backup.log 2>&1

Method 2: Off-Site Backups with restic

Restic is a modern backup tool with encryption and deduplication:

# Install restic
sudo apt install restic -y

# Initialize repository (S3-compatible storage)
restic -r s3:s3.amazonaws.com/my-backups init

# Run backup
restic -r s3:s3.amazonaws.com/my-backups backup /var/www /etc

# Set retention policy
restic -r s3:s3.amazonaws.com/my-backups forget --keep-daily 7 --keep-weekly 4 --keep-monthly 6 --prune

Testing Your Backups

A backup that has never been tested is not a backup. Schedule monthly restore tests:

  • Restore files to a temporary directory and verify integrity
  • Test database dumps by importing into a staging environment
  • Document the restore procedure so any team member can execute it

Was this article helpful?

Related Articles

Back to Server Management All Categories