Docs / Backup & Recovery / Testing Your Backups: Restore Verification Guide

Testing Your Backups: Restore Verification Guide

By Admin · Feb 25, 2026 · Updated Apr 23, 2026 · 154 views · 2 min read

Why Test Restores?

A backup that cannot be restored is worthless. According to industry surveys, up to 30% of backup restores fail due to corrupted files, missing data, or untested procedures. Regular testing is essential.

Database Restore Test

# Create a test database
mysql -u root -e "CREATE DATABASE restore_test;"

# Restore from backup
gunzip < /backups/mysql/mydb_latest.sql.gz | mysql -u root restore_test

# Verify data
mysql -u root restore_test -e "SELECT COUNT(*) FROM users;"
mysql -u root restore_test -e "SHOW TABLES;"

# Clean up
mysql -u root -e "DROP DATABASE restore_test;"

File Restore Test

# Create restore directory
mkdir /tmp/restore-test

# Restore from tar backup
tar xzf /backups/www-latest.tar.gz -C /tmp/restore-test

# Compare with original
diff -rq /var/www/html /tmp/restore-test/var/www/html

# Clean up
rm -rf /tmp/restore-test

Full Server Restore Test

  1. Deploy a temporary Breeze (test environment)
  2. Restore all backups (files, database, configuration)
  3. Verify the application works end-to-end
  4. Check all critical features
  5. Destroy the test server

Automated Verification Script

#!/bin/bash
BACKUP_FILE="/backups/mysql/mydb_latest.sql.gz"
TEST_DB="restore_verify_$(date +%s)"

# Test that backup file exists and is not empty
if [ ! -s "$BACKUP_FILE" ]; then
    echo "FAIL: Backup file missing or empty" | mail -s "Backup Verify Failed" admin@example.com
    exit 1
fi

# Test restore
mysql -u root -e "CREATE DATABASE $TEST_DB;"
gunzip < "$BACKUP_FILE" | mysql -u root "$TEST_DB" 2>/tmp/restore_error.log

if [ $? -ne 0 ]; then
    echo "FAIL: Restore failed" | mail -s "Backup Verify Failed" admin@example.com
    mysql -u root -e "DROP DATABASE IF EXISTS $TEST_DB;"
    exit 1
fi

# Verify table count
TABLES=$(mysql -u root "$TEST_DB" -e "SHOW TABLES;" | wc -l)
if [ "$TABLES" -lt 2 ]; then
    echo "FAIL: Only $TABLES tables found" | mail -s "Backup Verify Failed" admin@example.com
fi

mysql -u root -e "DROP DATABASE $TEST_DB;"
echo "Backup verification passed: $TABLES tables restored successfully"

Schedule Monthly Tests

0 4 1 * * /usr/local/bin/verify-backup.sh >> /var/log/backup-verify.log 2>&1

Was this article helpful?