[00] Subset Sync, User guide
Off-site backups
Copy every Subset Sync backup to Amazon S3 or an S3-compatible service, encrypt it if you choose, and restore it from there.
With Subset Sync Pro 0.10.0 or later, every backup is copied to storage off the server once it’s finished: the scheduled ones, the ones taken before a migration and Back up now. A backup kept only on the server it protects is lost if that server is. This page covers setting up the storage, encrypting backups, restoring one and limiting the keys to one folder.
Any service that works with the Amazon S3 API will do:
| Service | Endpoint | Region | Path-style |
|---|---|---|---|
| Amazon S3 | Leave it empty | The bucket’s, e.g. eu-west-1 | Off |
| Backblaze B2 | https://s3.<region>.backblazeb2.com | e.g. us-west-004 | Off |
| Wasabi | https://s3.<region>.wasabisys.com | e.g. eu-central-1 | Off |
| Cloudflare R2 | https://<account ID>.r2.cloudflarestorage.com | auto | Off |
| DigitalOcean Spaces | https://<region>.digitaloceanspaces.com | e.g. nyc3 | Off |
| MinIO | Your server’s address, e.g. https://minio.example.com | us-east-1 | On |
Set up the storage
- Create a private bucket, and keys that can use it. On Amazon S3, use the policy for one folder below.
- Open Subset → Migration → Backups and scroll to Off-site storage.
- Fill in Endpoint, Region and Bucket from the table above.
- Check Folder. Backups go in this folder of the bucket, and Subset Sync only lists and deletes files in it. It defaults to
subset-sync/and the site’s domain, so give each site its own if they share a bucket. - Paste the Access key ID and Secret access key.
- Set Backups to keep in storage. The default is 7.
- Click Save and test.
The test uploads a small file, lists the folder, reads the file back and deletes it. It also checks that the file can’t be downloaded without the keys, and fails if it can: anyone could then download your backups. On Amazon S3 it also checks that the bucket blocks public access.
Upload now uploads the newest backups that aren’t in storage yet. Otherwise each backup is uploaded in the background as soon as it’s finished. A backup taken before a migration goes within the hour.
The keys are stored encrypted and never shown again: their fields stay empty, and an empty field keeps the saved key. A database pull, import or restore never carries the keys or the storage settings to another site, so a staging copy of your site never uploads to production’s folder.
How uploads work
Large backups are uploaded in 50 MB parts, a few at a time, so a 2 GB backup never has to fit in one request. If the site stops partway, the upload carries on from the last part that was stored.
After each upload, the oldest backups in the folder beyond Backups to keep in storage are deleted. This number is separate from how many backups the site keeps. Files in the folder that aren’t Subset Sync backups are never deleted.
If a part fails, it’s tried again after 1, 2, 4, 8 and 16 minutes. After the sixth failure the upload stops and the backup stays on the site. Tools → Site Health then shows A backup couldn’t be uploaded to off-site storage, and the site admin gets an email, unless Email the site admin when a scheduled backup fails, or a backup can’t be uploaded to off-site storage is unticked under Scheduled backups. The next backup tries again.
Encrypt backups
A backup holds every user’s email address and password hash. To encrypt backups before they leave the site:
- Tick Encrypt backups with a passphrase before they’re uploaded.
- Type a Passphrase of at least 12 characters.
- Click Save storage.
Encrypted backups are named with .enc at the end and use libsodium’s XChaCha20-Poly1305, with the key derived from your passphrase.
A new passphrase applies to the next upload. Backups already in storage still need the passphrase they were encrypted with.
Restore a backup from storage
- Open Subset → Migration → Backups and scroll to Backups in storage.
- Click Download to restore next to the backup. For an encrypted one, type its passphrase first.
- Reload the page until it says the backup is on this site.
- Restore it from the list of backups at the top of the tab, as you would any other.
A wrong passphrase is refused straight away. A download that’s cut short is never listed as a backup.
On the command line, wp subset sync storage restore <name> downloads the backup and restores it in one go. See WP-CLI commands.
Limit the keys to one folder
Subset Sync only reads, writes, lists and deletes files in its folder, so on Amazon S3 the keys need no more than this. Replace example-backups with your bucket and subset-sync/example.com with your folder:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListTheFolder",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::example-backups",
"Condition": { "StringLike": { "s3:prefix": "subset-sync/example.com/*" } }
},
{
"Sid": "ReadWriteTheFolder",
"Effect": "Allow",
"Action": ["s3:PutObject", "s3:GetObject", "s3:DeleteObject", "s3:AbortMultipartUpload"],
"Resource": "arn:aws:s3:::example-backups/subset-sync/example.com/*"
},
{
"Sid": "CheckPublicAccessBlock",
"Effect": "Allow",
"Action": "s3:GetBucketPublicAccessBlock",
"Resource": "arn:aws:s3:::example-backups"
}
]
}
Attach it to an IAM user of its own and create that user’s access key. The last statement only lets the test check the bucket’s public access block. Leave it out and the test says it couldn’t check.
Turn on Block all public access for the bucket. Backblaze B2, Wasabi, R2 and Spaces have their own ways to make a bucket private and to limit a key to one bucket. Use them.
Set the keys in wp-config.php
To keep the keys out of the database, set them in wp-config.php. The fields then show as locked.
<?php
define( 'SUBSET_MIG_PRO_S3_KEY', 'AKIA…' );
define( 'SUBSET_MIG_PRO_S3_SECRET', '…' );
define( 'SUBSET_MIG_PRO_BACKUP_PASSPHRASE', '…' ); // Only if you encrypt backups.
If the site’s salts change, keys saved on the screen can’t be read any more. Nothing is uploaded until you enter them again, and Site Health says so.
Stop uploading
Click Remove storage to stop uploading and forget the storage’s settings and the keys saved on the screen. The backups already in storage stay there.