Knowledge Base – Managing Storage

Backups – A Comprehensive Guide

Backups protect your data against loss, corruption, and accidental deletion. This guide walks you through planning, executing, and verifying backups for both local and cloud environments.

Why Backups Matter

Backup Types

Type Description Typical Use
FullA complete copy of all selected data.Weekly, baseline.
IncrementalOnly changes since the last backup.Daily/Multiple times per day.
DifferentialChanges since the last full backup.Mid‑frequency restores.

Best Practices

  1. Apply the 3‑2‑1 rule: 3 copies, 2 different media, 1 off‑site.
  2. Encrypt data at rest and in transit.
  3. Automate backup scheduling and verification.
  4. Test restores quarterly.
  5. Retain backups according to compliance requirements.

Creating a Backup with rsync

Below is a simple script for performing an incremental backup using rsync. It stores backups in timestamped directories.

#!/bin/bash
SRC="/var/www"
DEST="/mnt/backups/www"
DATE=$(date +%Y%m%d_%H%M)

# Create a new backup directory
mkdir -p "$DEST/$DATE"

# Perform the rsync copy
rsync -a --delete --link-dest="$DEST/latest" "$SRC/" "$DEST/$DATE/"

# Update the 'latest' symlink
ln -sfn "$DEST/$DATE" "$DEST/latest"

Backing Up to Cloud (AWS S3)

Use the AWS CLI to sync a local folder to an S3 bucket.

aws s3 sync /var/www s3://my-backup-bucket/www --delete --storage-class STANDARD_IA

Verification & Monitoring

After each backup, run a checksum comparison to ensure integrity.

# Generate checksums for source
find /var/www -type f -exec sha256sum {} + > /tmp/src.sha256

# Generate checksums for backup
find /mnt/backups/www/latest -type f -exec sha256sum {} + > /tmp/dest.sha256

# Compare
diff /tmp/src.sha256 /tmp/dest.sha256 && echo "Verification passed" || echo "Verification failed"

FAQ

How often should I run a full backup?

Typically weekly, but adjust based on data change rate and retention policies.

Can I encrypt backups with rsync?

Encrypt the destination volume (e.g., LUKS) or pipe rsync through gpg for per‑file encryption.

What if my backup storage fills up?

Implement a retention script that deletes the oldest snapshots after a set threshold.