Docs / Surfaces / WordPress

WordPress sites

You back up a WordPress site with the SafeGrd Backup plugin, from wp-admin. You install nothing else on the server, so it works on shared and managed hosting. Each backup is a complete snapshot of the database and the site's files, encrypted on your server before it leaves.

Backups go to SafeGrd's hosted storage, locked so nobody can delete them early. You can use your own bucket instead, locked or not, as you set it up. A backup uploads only what changed since the last one. Pricing lists what each plan includes.

Install and connect

  1. In wp-admin, open Plugins, Add New, search for SafeGrd Backup, press Install Now, then Activate. The plugin is safegrd-backup in the WordPress.org directory, and its updates come from there too. If the site cannot reach WordPress.org, the same zip is on the plugin's releases.
  2. Open Tools, SafeGrd, choose how your key is managed, and press Connect. In the tab that opens, sign in or create an account. Check that the tab shows the same code as wp-admin, then press Connect site. To connect without the tab, open Connect with a token instead and paste a token from Tokens in the console.
Press Connect, check that the code in the SafeGrd tab matches, and approve it. The page refreshes on its own and finishes connecting once you approve. The first backup runs right after.

The first backup starts right after you connect. After that, a backup runs once a day (or once a week, under Settings) through WP-Cron, which runs when someone visits the site. To run one straight away, press Back up now on the same page.

# the same from WP-CLI, with a token from Tokens in the console
wp plugin install safegrd-backup --activate
wp safegrd connect --token=env:SAFEGRD_TOKEN
wp safegrd backup
Tools, SafeGrd in wp-admin, the Backups tab: protected, the last backup with its tables, rows, files and lock date, the next backup, the last test restore, the storage, the key, and the recent backups with their ids, Open and Log.
Tools, SafeGrd, Backups. Last test restore shows what SafeGrd checked on its own machines. Lock is the date until which nobody can delete the backup. In a bucket you set up without Object Lock, it says Not locked. Open shows a backup on the Restore & download tab.

How your key is managed

You choose this when you connect. With a SafeGrd-managed key, the default, SafeGrd keeps your key sealed and releases it only to your enrolled hosts, so you can restore even after losing this site. This is also what lets SafeGrd test-restore your backups for you.

With a Customer-managed key, only you can decrypt these backups. The plugin shows the key once, when you connect. Keep a copy somewhere safe, such as a password manager. The site keeps only the public half, so it can write backups but cannot read them.

Back up to your own bucket

You can keep a site's backups in your own S3 bucket instead of SafeGrd's, with Object Lock on or off. The site holds no storage key. SafeGrd signs each upload and read with the key it holds for the bucket.

  1. In the console, press Storage on the site's project, choose Your own bucket, and enter the bucket, its endpoint, its access key and its secret key. SafeGrd holds the secret key you enter.
  2. Press Test connection. The test has to pass with the key SafeGrd holds. It also has to find Object Lock on, unless you chose a bucket without it.
  3. The site's next backup goes to the bucket, and SafeGrd test-restores it there. Tools, SafeGrd and wp safegrd status show the bucket's name.

The first backup in the bucket uploads every file once. Each backup is locked for the project's retention, in the bucket's Object Lock mode. In a bucket you set up without Object Lock (worm_mode: NONE, such as DigitalOcean Spaces), backups are not locked, and Tools, SafeGrd shows them as Not locked.

SafeGrd deletes nothing in your bucket. To remove old backups, use the bucket's lifecycle rules, or run safegrd prune on a host with the key. The backups are filed the same way the CLI files a host's, under <prefix>/<node id>/repo/. A host with the bucket's key can verify and restore them without SafeGrd:

safegrd verify --snapshot snap-20261019-093000-1a2b3c --s3-bucket my-backups --s3-prefix sites --s3-access-key AKIA... --s3-secret-key env:S3_SECRET

If SafeGrd does not hold the bucket's key, or the bucket has not passed a test with it, the site stays on hosted storage and Tools, SafeGrd says why.

What is backed up

PartWhat is in the snapshot
DatabaseEvery table that starts with the site's $table_prefix, in the form mysqldump writes. The tables are read in one consistent snapshot, or table by table on a host that stops the request first. If another WordPress install shares the database and its prefix starts with yours (wp_shop_ beside wp_), its tables are left out and listed. Views and triggers are listed as left out too
Fileswp-config.php, .htaccess and wp-content: uploads, themes and plugins
Left outWordPress core (reinstall the version the backup names), caches, upgrade, debug.log, and other backup plugins' archives. Symlinks and unreadable files are listed after each run
Left out by youPaths and names you set under Tools, SafeGrd, Settings, such as wp-content/ewww or *.zip. You cannot leave out uploads, because the test restore checks every attachment. Each run lists what it left out and how many matched

Under Settings you choose daily or weekly backups and the hour they start, in the site's timezone. WP-Cron starts each one at the first visit after that hour. Tools, SafeGrd, Logs keeps the output of the last 20 backups, restores and downloads.

wp-config.php holds the database password and the site's salts. It is in the snapshot because a restore needs it, and it is encrypted with everything else.

The plugin refuses Multisite networks. It also refuses a site whose media another plugin keeps in object storage (WP Offload Media, WP-Stateless, Media Cloud), because those files are not on the server for it to read.

What the test restore checks

SafeGrd test-restores the newest backup on its own machines, in memory, on every plan. The drill fails if any of these fails:

Restore

You can restore from wp-admin on any host. Install WordPress, install the plugin, and connect it to the same account. Tools, SafeGrd, Restore & download lists this site's backups. The Site filter shows the backups of any other WordPress site in the account.

Open a backup to see what it holds: each part's size, the WordPress and PHP versions, and its plugins, themes and tables. Tick what to restore, press Review restore to see what will be replaced, then press Restore now. You can also restore a site over itself from the same page.

Opening the newest backup, restoring only its plugins and themes after the review, then downloading its uploads. The progress line at the top of the page follows each one, and the download is listed with its link when it is written.

Download a backup

You can download one part of a backup as a file from the same page. The database comes as a gzipped SQL dump. Plugins, themes, uploads or the rest of wp-content come as a gzipped tar, and the tar also carries wp-config.php and .htaccess. The plugin writes the file on the site's server, decrypted, in slices, and an administrator fetches it from wp-admin. It is deleted from the server a day later. From the command line: wp safegrd download <snapshot> uploads --to=uploads.tar.gz, or for single tables, plugins or themes, wp safegrd download <snapshot> database --tables=wp_posts --to=posts.sql.gz.

To restore a backup taken with a customer-managed key, open it on the same page and paste the key, or pass --key=file:/path/to/key to wp safegrd restore. The site checks that the key opens the backup. It keeps the key sealed until the restore swaps in, or for an hour if no restore starts, then deletes it.

To restore onto a server without WordPress, use the safegrd CLI on any host enrolled in the same organization. You need an empty MySQL or MariaDB database, an empty directory, and the mysql client.

# find the snapshot
safegrd list
# database into an empty database, files into an empty directory
safegrd restore --snapshot snap-20261006-120000-a1b2c3 \
--target mysql://wp:...@db.example.com:3306/wordpress --target-dir ./restored

The restore prints the snapshot's WordPress version and site URL. Then rebuild the site in the directory your web server serves, here /var/www/html:

# 1. WordPress core, at the version the restore printed
wp core download --version=6.8.3 --path=/var/www/html
# 2. the restored files over it
cp -a ./restored/. /var/www/html/
# 3. owned by the web server's user (www-data on Debian and Ubuntu)
chown -R www-data:www-data /var/www/html
# 4. wp-config.php pointed at the restored database
wp config set DB_NAME wordpress --path=/var/www/html
wp config set DB_USER wp --path=/var/www/html
wp config set DB_PASSWORD '...' --path=/var/www/html
wp config set DB_HOST db.example.com:3306 --path=/var/www/html
# 5. only on another domain: search and replace the old URL, serialized data included
wp search-replace 'https://old.example' 'https://new.example' --all-tables --skip-columns=guid --path=/var/www/html

If the site comes back at the same address, skip step 5. Otherwise run it with --dry-run first to see how many values it changes. Do not replace the URL as plain text in the SQL. That breaks serialized options, such as widget settings, because their recorded lengths no longer match.

The restored site is not connected to SafeGrd, because every backup leaves out the plugin's own settings. Connect it again from Tools, SafeGrd.

What each backup uploads

A backup uploads only the chunks this month's repository does not hold yet. Files are cut into 4 MiB chunks, encrypted and gathered into packs. Each table is its own part of the dump, so an unchanged image, theme or table costs nothing. The first backup of each month uploads everything once, so every month stands on its own. Every snapshot is complete, and a restore never needs an earlier one.

Large sites on strict hosts

The plugin runs a backup in slices of a few seconds, each its own request. A slice lasts a third of the host's max_execution_time, at most 25 seconds. Each slice uploads what it read, saves where it got to, and starts the next one. If the host stops a request, only that slice stops, and the next one resumes from the last saved point.

A file too large to read in one slice, such as a video, is stored 4 MiB at a time across as many slices as it needs. On a host that stops requests at 30 seconds, a 2 GB file backs up and restores this way.

A backup on a host that stops requests at 30 seconds, as four slices of up to 10 seconds each. After slices 1, 2 and 4 the plugin saves its place. The host stops slice 3, and slice 4 starts again from the save after slice 2, so the work of slice 3 is redone and nothing is lost. Slice 1 Slice 2 Slice 3 Slice 4 one request each: a third of a 30 s request limit stopped slice 4 starts from the last save dots: where the plugin saved its place
The host stops one slice, and the backup carries on from the save before it.

The plugin first reads the whole database in one request, as one consistent snapshot. On a host that stops requests at 30 seconds, a dump of about 1 GB fit only on a fast machine with MySQL's cache warm. If the host stops that request, the plugin reads the database table by table across slices instead. Each slice reads its tables in a consistent snapshot of its own. It reads a large table a page of rows at a time, by primary key rather than by position, so rows added or deleted in the meantime do not shift the pages. A table with no primary key is read whole in one slice.

That backup still holds every table, but the tables were read at different moments, a few seconds to minutes apart. The plugin says so in its log and on Tools, SafeGrd. The snapshot in the console says so too, with the time span. The backup's manifest lists what each request read and when.

To get one consistent snapshot of a large site, run backups from the server's cron, where WP-CLI has no time limit. Then turn off WP-Cron's own trigger with define('DISABLE_WP_CRON', true);:

17 3 * * * cd /var/www/html && wp safegrd backup --quiet

Requirements

The plugin needs PHP 7.4 or newer with the sodium, zlib and mysqli extensions, which PHP includes by default. To use a self-hosted SafeGrd server, set define('SAFEGRD_SERVER_URL', 'https://...');. For a private CA, set define('SAFEGRD_CA_FILE', '/path/to/ca.pem');.