# Automate backups and test restores

- Check 09.09 · Security and infrastructure · Critical
- Source: https://checklist-seo-geo.com/en/security-infrastructure/automate-backups-test-restores
- Automate off-site, encrypted and versioned backups on a server, cPanel, Plesk, AWS, WordPress or Laravel, then test the restore before you ever need it.
- Updated on 2026-11-25
- Licence: CC BY 4.0. Credit “Checklist SEO & GEO” with a link to https://checklist-seo-geo.com/en/security-infrastructure/automate-backups-test-restores.
- Plugin checklist-seo-geo: 1.3.1 · https://github.com/maximegaul/checklist-seo-geo

## In short

A backup is only worth something if it can be restored. This check is about automatically copying the site's files and database off the server, keeping several versions, then regularly checking that a full restore works and how long it takes. Once this is in place, a hack, a failed update or an accidental deletion is repaired in a few hours, not a few weeks.

## Why it matters

The incidents that destroy a site are mundane: a plugin update that breaks the database, ransomware, a folder deleted by mistake, a failing host, a suspended account. Without a recent, usable copy, pages have to be rebuilt by hand, and in the meantime the site returns errors.

For SEO, the length of the outage matters. Google reduces its crawl rate when a server returns errors, and pages that stay in error or 404 for a long time eventually drop out of the index. After a hack, restoring a clean version lets you clean up quickly and then [request a review](https://checklist-seo-geo.com/en/security-infrastructure/check-search-console-security-issues); generative engines, for their part, keep citing the pages they find, clean or not.

The most common failures do not come from having no backup, but from unusable backups: stored on the compromised server, encrypted by the same ransomware, incomplete (files without the database, or the other way round), corrupted, or too old. Only a restore test reveals this.

## What it improves

- **Incident recovery**: short, controlled downtime.
- **Preserved indexing**: an outage of a few hours has little effect; an outage of several days can push pages out of the index.
- **Post-hack cleanup**: a known clean version serves as a reference to spot modified files.
- **Calmer updates**: rolling back is possible. See [prepare a rollback plan](https://checklist-seo-geo.com/en/redesign-migration/prepare-rollback-plan).
- **Compliance**: the availability and restoration of personal data are part of the security measures expected under the GDPR (General Data Protection Regulation).
- **Rankings**: no direct effect.

## How to check

Answer these six questions; a single “no” or “I don't know” justifies this check.

1. Is the backup automatic, with no human action?
2. Does it contain the files **and** the database?
3. Is it stored off the site's server, with another provider or in another account?
4. Does it keep several versions (at least 30 days)?
5. Is an alert sent when a backup fails?
6. Have you restored the full site from a backup within the last three months?

Quick check on a server:

```bash
ls -lh --time-style=long-iso /var/backups/example/ | tail -5
crontab -l | grep -i -E "backup|sauvegarde|restic|mysqldump"
```

The most recent backup should be less than 24 hours old and similar in size to the previous ones. An archive of a few kilobytes signals a silent failure.

## How to implement

### Before you start

Set two objectives and write them down in the site's documentation:

- **RPO** (Recovery Point Objective, the maximum acceptable data loss): one day for a brochure site, one hour or less for a store that takes orders.
- **RTO** (Recovery Time Objective, the maximum time to get back online): a few hours for most sites.

Then apply the so-called 3-2-1 rule, an industry convention: three copies of the data, on two different media, one of them off site. Add a copy that the server cannot erase (object storage with versioning or object lock, a separate account): that is the one that survives ransomware or an attacker who has taken control of the server.

What to back up:

| Item | Examples | Frequency |
|---|---|---|
| Database | MySQL, MariaDB, PostgreSQL | Daily, or hourly for e-commerce |
| Uploaded files | `wp-content/uploads`, `storage/app`, PrestaShop's `img/` | Daily |
| Code and configuration | theme, plugins, `.env`, server configuration | On every deployment (the Git repository covers this, except `.env`) |
| External settings | DNS zone, CDN rules, redirects | On every change |

Recommended retention: 7 daily backups, 4 weekly, 6 to 12 monthly. Encrypt backups that contain personal data and keep the encryption key somewhere other than the server.

> **Warning:** a backup stored on the same server, or reachable with the same credentials as the site, disappears with it. Remote storage must use dedicated credentials, limited to writing if the service allows it.

### Apache

Versions: Apache 2.4.

The web server itself is not the concern: back up its configuration (`/etc/apache2/` or `/etc/httpd/`) along with the site's files, and use the script from the Nginx section, which is identical for Apache.

### Nginx

Versions: any version of Nginx; restic 0.17 and later; MySQL 8.0 and later, MariaDB 10.6 and later or PostgreSQL 13 and later.

On a Linux server, restic produces encrypted, deduplicated and versioned backups to remote storage (S3, Backblaze B2, SFTP, or any service via rclone). Initialize the repository once:

```bash
export RESTIC_REPOSITORY="s3:s3.amazonaws.com/sauvegardes-example"
export RESTIC_PASSWORD_FILE="/root/.restic-mot-de-passe"
export AWS_ACCESS_KEY_ID="CLE_DEDIEE"
export AWS_SECRET_ACCESS_KEY="SECRET_DEDIE"
restic init
```

Daily script `/usr/local/bin/sauvegarde-example.sh`:

```bash
#!/usr/bin/env bash
set -euo pipefail
source /root/.restic-env

DOSSIER_DUMP="/var/backups/example"
mkdir -p "$DOSSIER_DUMP"

mysqldump --single-transaction --routines --triggers --default-character-set=utf8mb4 \
  example_db | gzip > "$DOSSIER_DUMP/example_db.sql.gz"

restic backup /var/www/example /etc/nginx "$DOSSIER_DUMP" \
  --exclude "/var/www/example/storage/framework/cache" --tag quotidienne

restic forget --keep-daily 7 --keep-weekly 4 --keep-monthly 12 --prune
restic check --read-data-subset=5%

curl -fsS -m 10 https://hc-ping.com/IDENTIFIANT_DE_LA_SONDE > /dev/null
```

The `/root/.restic-env` file contains the environment variables from the initialization (permissions `600`). MySQL credentials go in `/root/.my.cnf` so they do not appear in the script. The last line reports success to a scheduled-job monitoring service such as Healthchecks.io: if it receives nothing during the day, it alerts you. That is how you detect a backup that fails silently.

Scheduling with `sudo crontab -e`:

```txt
30 3 * * * /usr/local/bin/sauvegarde-example.sh >> /var/log/sauvegarde-example.log 2>&1
```

For PostgreSQL, replace the `mysqldump` line with `pg_dump -Fc example_db > "$DOSSIER_DUMP/example_db.dump"`. On MariaDB 11, the command is called `mariadb-dump`: the old `mysqldump` name is deprecated and prints a warning.

### Cloudflare

Versions: Cloudflare dashboard, all plans, November 2026.

Cloudflare does not back up your site: even with caching, a page that is no longer on the origin eventually disappears. Export the DNS zone (`DNS > Records`, Import and Export button) after every change, and write down your rules. R2 storage can serve as an S3-compatible destination for restic.

### AWS

Versions: AWS console (AWS Backup, Amazon RDS, Amazon S3, Lightsail), November 2026.

- **EC2 and EBS**: create a plan in [AWS Backup](https://console.aws.amazon.com/backup/home) (`Backup plans > Create backup plan`), with a daily rule and 35-day retention, then assign volumes to it by tag. Enable Vault Lock if you want backups that cannot be deleted.
- **RDS**: automated backups and point-in-time recovery are enabled in the instance settings, with retention adjustable up to 35 days. They disappear with the instance unless you choose to keep them: also keep manual snapshots or a copy in another account.
- **S3**: enable versioning on the bucket that receives the files or the backups.

```bash
aws s3api put-bucket-versioning --bucket sauvegardes-example --versioning-configuration Status=Enabled
```

- **Lightsail**: enable automatic snapshots in the instance's Snapshots tab.

### Google Cloud

Versions: Google Cloud console and gcloud CLI (Cloud SQL, Compute Engine), November 2026.

**Cloud SQL** enables automated backups by default; check the retention and enable point-in-time recovery under the instance's `Backups`. **Compute Engine**: schedule disk snapshots.

```bash
gcloud compute resource-policies create snapshot-schedule sauvegarde-quotidienne \
  --region=europe-west1 --daily-schedule --start-time=02:00 --max-retention-days=30
gcloud compute disks add-resource-policies DISQUE --resource-policies=sauvegarde-quotidienne --zone=europe-west1-b
```

### Azure

Versions: Azure portal, App Service (Basic tier and above) and Azure Backup, November 2026.

**App Service** creates automatic backups every hour on the Basic tier and above, kept for 30 days, but without the linked database, and stored in the same datacenter: Microsoft advises against making them your recovery plan. Also configure scheduled custom backups (`Backups > Configure custom backups`, then set a backup schedule) to a storage account, and back up the database with the native tools of Azure Database (Azure SQL, Azure Database for MySQL or PostgreSQL Flexible Server). The option to include the linked database in a custom backup is no longer offered for new configurations since 2026, and Microsoft will remove it entirely on March 31, 2028. For a virtual machine, use Azure Backup with a Recovery Services vault.

### Plesk

Versions: Plesk Obsidian 18.0.

`Websites & Domains > Backup Manager > Schedule` ([Plesk documentation](https://docs.plesk.com/en-US/obsidian/administrator-guide/backing-up-and-restoration/scheduling-backups.59264/)): tick the box that activates the task, choose the frequency, the time, the remote storage (FTP, S3, Google Drive depending on the extensions installed) and a retention period. Choose incremental backups with a periodic full backup, and password-protect the archive. The server administrator sets the global schedule in `Tools & Settings > Backup Manager`.

### cPanel

Versions: cPanel & WHM 124 and later.

The `Files > Backup` tool ([cPanel documentation](https://docs.cpanel.net/cpanel/files/backup-for-cpanel/)) produces on-demand backups, not scheduled ones. A full account backup cannot be restored from cPanel: it has to go through the host (WHM), or be restored piece by piece. Partial backups (home directory, MySQL databases) are restored from the same screen.

To automate:

- use the host's scheduled backups (often JetBackup, visible in cPanel if it is installed), checking their retention and whether you can restore by yourself;
- add a copy outside the host: a CMS plugin to external storage, or a `mysqldump` cron job from `Advanced > Cron Jobs`.

### Shared hosting

The host's backups are a safety net, not a strategy: short retention, restores that are sometimes charged for, and they disappear if the account is suspended or hacked. Keep your own external copy, with your CMS's backup plugin or a scheduled task, and download a full copy at least once a month.

### WordPress

Versions: WordPress 6.4 and later; UpdraftPlus 1.26; WP-CLI 2.10 and later.

UpdraftPlus (free version) schedules backups of files and the database to remote storage: `Settings > UpdraftPlus Backups > Settings`, separate schedules for files and database, number of copies to keep, destination (Google Drive, Dropbox, S3, SFTP). Managed WordPress hosts provide daily backups: check their retention and test a restore.

From the command line, with WP-CLI:

```bash
wp db export /var/backups/example/base-$(date +%F).sql
tar -czf /var/backups/example/uploads-$(date +%F).tar.gz -C /var/www/example/wp-content uploads
```

A backup placed in `wp-content` can be downloaded by anyone who guesses its name: store it outside the public folder.

### Shopify

Versions: Shopify admin, all plans, November 2026.

Shopify hosts the platform, but does not offer to restore your store to an earlier state. Regularly export products, customers and orders to CSV from the admin, and download the theme (`Online Store > Themes`, “…” menu, Download theme file). For automatic backups with restore, use a dedicated app from the App Store.

### Laravel

Versions: Laravel 10 to 13; spatie/laravel-backup 9 (Laravel 10 to 12) and 10 (Laravel 12.40 and later, Laravel 13).

The spatie/laravel-backup package backs up files and the database to any configured disk (S3, SFTP) and sends notifications on failure.

```bash
composer require spatie/laravel-backup
php artisan vendor:publish --provider="Spatie\Backup\BackupServiceProvider" --tag=backup-config
```

Composer installs the version of the package compatible with your Laravel and PHP (version 10 requires PHP 8.4). In `config/backup.php`, choose the remote disk in `backup.destination.disks` and an address in `notifications.mail.to`. `backup:monitor` alerts you if the latest backup is too old or too large. Laravel's scheduler must be run every minute by cron: `* * * * * cd /var/www/example && php artisan schedule:run >> /dev/null 2>&1`. Only the place where tasks are declared changes with the version.

#### Laravel 11 to 13

Schedule in `routes/console.php`:

```php
use Illuminate\Support\Facades\Schedule;

Schedule::command('backup:clean')->daily()->at('01:00');
Schedule::command('backup:run')->daily()->at('01:30');
Schedule::command('backup:monitor')->daily()->at('09:00');
```

An application upgraded from Laravel 10 without changing its structure may keep its `app/Console/Kernel.php`: follow the next tab in that case.

#### Laravel 10

Schedule in the `schedule()` method of `app/Console/Kernel.php`:

```php
protected function schedule(Schedule $schedule): void
{
    $schedule->command('backup:clean')->daily()->at('01:00');
    $schedule->command('backup:run')->daily()->at('01:30');
    $schedule->command('backup:monitor')->daily()->at('09:00');
}
```

### Vercel

Versions: Vercel platform, all plans, November 2026.

The code lives in your Git repository and every deployment remains available for an instant rollback; there is nothing else to back up on the Vercel side. The data lives elsewhere (database, storage, headless CMS): back it up with its provider.

### Testing the restore

Once a quarter, and after every infrastructure change:

1. Create an isolated environment, password-protected and not indexable.
2. Restore the most recent backup, files and database, timing the operation.
3. Check: home page, a deep page, a recent image, admin login, latest published content, latest order.
4. Record the date, the backup used, the duration and any problems encountered in a log.
5. Destroy the test environment, which contains real data.

With restic, a restore into a temporary folder:

```bash
restic snapshots --tag quotidienne
restic restore latest --target /tmp/restauration-test
gunzip -c /tmp/restauration-test/var/backups/example/example_db.sql.gz | mysql example_test
```

If the measured duration exceeds your RTO, simplify the procedure or change tools before an incident forces you to.

## Common mistakes

- **Backing up to the server itself**: the copy disappears with the outage, the hack or the account suspension.
- **Never testing the restore**: on the day it matters, you discover an empty database, a corrupted archive or a lost encryption password.
- **Forgetting the database, or the uploaded files**: the code alone contains neither the content nor the images.
- **Keeping a single version**: if last night's backup already contains the hack, there is no clean version left.
- **Leaving archives in the public folder**: a `backup.zip` file at the root exposes the whole database. See [protect private information with access control](https://checklist-seo-geo.com/en/security-infrastructure/protect-private-information-access-control).
- **No alert on failure**: a failing cron job warns nobody.
- **Restoring a hacked site without fixing the vulnerability**: the site is reinfected within days.

## Frequently asked questions

### Are my host's backups enough?

Rarely. Backups from a shared host often have short retention, restores that are sometimes charged for or slow, and they are stored with the same provider: if the account is suspended, hacked or closed, they become inaccessible. Keep them as a safety net, but add an automatic, encrypted and versioned copy outside the host, one you know how to restore yourself.

### How often should a website be backed up?

The frequency depends on how much data you are willing to lose. A daily backup suits most brochure sites and blogs. An online store that receives orders all day long should back up its database every hour, or enable point-in-time recovery with its provider. Keep several versions, for example seven daily, four weekly and several monthly ones.

### How can I test a restore without breaking the production site?

Restore into a separate environment: a password-protected subdomain, a temporary machine or a local container. Load the files and database from the latest backup, then check the home page, a deep page, a recent image, the admin login and the latest published content. Time the operation, record the result, then destroy this environment, which contains real data.

### Does an outage of several days cost search rankings?

A short outage has little lasting effect: Google temporarily reduces its crawling and then comes back. When pages stay in error or not found for several days, they can drop out of the index and lose their positions until they are crawled again. A tested backup cuts that time down to a few hours. During planned maintenance, return a 503 code rather than an error page with a 200.

## Resources

- [restic: documentation](https://restic.readthedocs.io/)
- [AWS Backup: Developer Guide](https://docs.aws.amazon.com/aws-backup/latest/devguide/whatisbackup.html) and [Amazon RDS: automated backups](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_WorkingWithAutomatedBackups.html)
- [Azure App Service: Back up an app](https://learn.microsoft.com/en-us/azure/app-service/manage-backup)
- [Plesk: Scheduling backups](https://docs.plesk.com/en-US/obsidian/administrator-guide/backing-up-and-restoration/scheduling-backups.59264/)
- [cPanel: Backup](https://docs.cpanel.net/cpanel/files/backup-for-cpanel/)
- [Shopify: backups and duplication](https://help.shopify.com/en/manual/shopify-admin/duplicate-store)
- [spatie/laravel-backup: documentation](https://spatie.be/docs/laravel-backup/)
- [Google Search Central: Pause or disable a website](https://developers.google.com/search/docs/crawling-indexing/pause-online-business)

Next steps: [monitor uptime and alerts](https://checklist-seo-geo.com/en/security-infrastructure/monitor-uptime-alerts) and [use 503 during temporary maintenance](https://checklist-seo-geo.com/en/http-redirects/use-503-during-temporary-maintenance).
