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
- 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.
- 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.
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.
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.
- 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.
- 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.
- The site's next backup goes to the bucket, and SafeGrd test-restores it there. Tools,
SafeGrd and
wp safegrd statusshow 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_SECRETIf 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
| Part | What is in the snapshot |
|---|---|
| Database | Every 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 |
| Files | wp-config.php, .htaccess and wp-content: uploads, themes and plugins |
| Left out | WordPress 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 you | Paths 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:
- Every pack the snapshot names is in storage and opens with the key. The snapshot's content root matches the one recorded when it was taken.
- The database dump is complete, and every table has the rows the backup counted.
- Every file matches the size and SHA-256 listed beside it, and no file is unlisted.
- Every attachment the database names (
_wp_attached_file) is a file in the snapshot. The list comes from the database half of the backup, so a missing upload fails the drill by name.
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.
- The site keeps running on its own database and files while the restore loads and checks everything: every table's rows against the backup, every file against its SHA-256. Then one step swaps the restored ones in.
- The restore keeps the tables and files it replaced. Put the copy back
undoes the restore by swapping them with what it put in. The restored version is then the
copy kept aside, so pressing the button again restores it again. Delete the copy
frees the space. Copies kept by earlier restores are listed with their size. From the
command line:
wp safegrd restore --undo,--delete-copyor--delete-older. - The site keeps its own
wp-config.phpand domain. If the URL differs, the restore runs a search and replace from the old URL to the new one, serialized data included, and renames the tables to the new table prefix. - After the restore, the site's users are the ones in the backup. Sign in with an administrator account of the restored site. The site stays connected to SafeGrd.
- You can restore only some parts: the database, plugins, themes, uploads, and the rest of wp-content. If you leave out the database, the site keeps its content, settings and sign-in. Plugin settings stay as they are too, because they live in the database. The SafeGrd plugin itself always stays at the version that is running.
- You can also restore single plugins, themes or tables. Some plugins
only, Some themes only and Some tables only list what the backup
holds. For each plugin and theme, they show the version in the backup and the one installed
now. Each one you tick replaces its own directory or table, and everything else stays as it
is. Use this to roll back one plugin after an update, or to bring back the posts table
alone. Restoring the users table brings back the backup's users with it.
From the command line:
wp safegrd contents <snapshot>lists them, thenwp safegrd restore <snapshot> --plugins=akismetor--tables=wp_posts,wp_postmeta. - While updates are waiting, the Updates, Plugins and Themes screens in wp-admin show how old the last backup is, next to Back up now.
- A restore runs in slices, like a backup, so a host that stops long requests does not stop
it. From the command line:
wp safegrd snapshots, thenwp safegrd restore <snapshot>, orwp safegrd restore <snapshot> --only=plugins,themes.
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.
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:
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.
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);:
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');.