Why Test?
A backup that cannot be restored is worthless. Regular testing ensures your backup process actually works when you need it.
Database Restore Test
#!/bin/bash
# Create temporary database
mysql -u root -e "CREATE DATABASE backup_test"
# Restore latest backup
gunzip < /backup/mysql/mydb_latest.sql.gz | mysql -u root backup_test
# Verify data
ROWS=$(mysql -u root -N -e "SELECT COUNT(*) FROM backup_test.users")
echo "Users table has $ROWS rows"
# Compare with production
PROD_ROWS=$(mysql -u root -N -e "SELECT COUNT(*) FROM mydb.users")
echo "Production has $PROD_ROWS rows"
# Cleanup
mysql -u root -e "DROP DATABASE backup_test"File Restore Test
#!/bin/bash
RESTORE_DIR=$(mktemp -d)
tar -xzf /backup/www_latest.tar.gz -C "$RESTORE_DIR"
# Check key files exist
for file in index.php wp-config.php .htaccess; do
if [ -f "$RESTORE_DIR/var/www/html/$file" ]; then
echo "OK: $file exists"
else
echo "FAIL: $file missing!"
fi
done
rm -rf "$RESTORE_DIR"Automated Monthly Test
# Run on the 1st of each month
0 5 1 * * /root/scripts/test-backup.sh | mail -s "Backup Test Report" admin@example.comChecklist
- Can you restore the database? (SQL import succeeds)
- Does the data look correct? (row counts, recent records)
- Are all application files present?
- Are config files included?
- How long does a full restore take? (measure your RTO)