Every team that deploys WordPress from Git eventually has the same bad afternoon. A release goes out, something in it interacts badly with live data, and the question is how far back you can go. If the answer is “the nightly backup”, you are about to lose every order, comment, and form entry since midnight, or spend the evening merging them back by hand.
The fix is old and simple: take a WordPress backup before deploy, every time, immediately before each release. The reason it does not happen is that it depends on someone remembering to click a button in wp-admin at the exact moment they are focused on something else.
So take the person out of it. Snapshotify, the DaftPlug backup plugin, exposes the same REST endpoints its admin screen uses, and its documentation includes a section on exactly this use: backing up from a deploy script. This guide walks through setting it up safely, waiting for the backup to finish before you release, and the details that trip people up.
What the API offers
Snapshotify registers its endpoints under the snapshotify/v1 namespace:
https://example.com/wp-json/snapshotify/v1/
The documentation is upfront that these serve the plugin’s own admin screen, so you should treat them as an internal API rather than a versioned public contract. That is a reason to keep your script small and to read the changelog when you update, not a reason to avoid it.
For a deploy pipeline you need three of them:
| Endpoint | Method | What it does |
|---|---|---|
/backup/create | POST | Starts a backup. Takes a title, an exclusions array, and a location. Returns immediately with an ID. |
/backup/progress | GET | Progress for a running job. Polling it also advances the job. |
/backup/logs | GET | The activity log for one backup, including any warning that did not stop the job. |
Every one of these requires manage_options, which is administrator-level access. The only endpoint without a capability check is the token-gated /restore/relogin, which exists for landing back in wp-admin after a restore and is not something a deploy script should touch.
Step one: a dedicated user and an application password
A deploy script runs outside a browser session, so it cannot use the cookie and nonce the admin screen uses. The docs’ deploy example authenticates with a WordPress application password instead.
- Create a new administrator user just for automation, for example
deploy. The docs are explicit: create a dedicated user for automation rather than reusing your own account. - In that user’s profile, under Application Passwords, create one named after the pipeline, such as “GitHub Actions production”.
- Store it as a secret in your CI system. Never commit it to the repository.
A dedicated user gives you a clean audit trail and a clean off switch. If the pipeline changes hands or a secret leaks, revoke that one application password and nothing else breaks.
Step two: start the backup
This is the request from the Snapshotify documentation:
curl -X POST https://example.com/wp-json/snapshotify/v1/backup/create \
-u "deploy:xxxx xxxx xxxx xxxx xxxx xxxx" \
-H "Content-Type: application/json" \
-d '{"title": "Pre-deploy '"$(date -I)"'", "exclusions": [], "location": "google-drive"}'
Three fields shape the backup.
title. Name it for the reason you took it. The creating backups guide recommends this so that months later you can tell which archive you want. Including the date, the commit hash, or the release tag makes a pre-deploy backup easy to find in a list that also contains scheduled ones.
exclusions. An empty array means a full-site backup. To leave things out, the settings keys reference lists the values the create call accepts: excludeCore, excludeMediaLibrary, excludePlugins, excludeThemes, and excludeDatabase. Excluding all five is refused with a nothing_to_backup error. The docs describe the field as an array using those keys, so send a test request on staging to confirm the shape your version accepts before it goes into the pipeline.
location. Where the archive goes. The docs’ examples use local and google-drive. Cloud storage (Google Drive, OneDrive, and Dropbox) is a Pro feature and the provider must be connected on the site first, under Settings > Storage.
Choosing scope for a deploy
What you exclude depends on what the release can break.
- Code releases that ship themes and plugins from Git. The code is already in your repository, so the thing you cannot recreate is the database and the uploads. A backup excluding core is a reasonable default, since the docs note core is re-downloadable and its version is recorded in the manifest.
- Releases that run database migrations. Never exclude the database. It is the whole point.
- Very large media libraries. Excluding
excludeMediaLibrarymakes the pre-deploy backup much faster, as long as a scheduled full backup covers media separately.
The general settings guide is blunt about the opposite case: a files-only backup is almost never right, because the database holds your posts, pages, settings, users, and orders.
Step three: wait until it has actually finished
This is the part most scripts get wrong. The create call returns as soon as the job starts, not when it finishes. If your script deploys the moment it gets a response, you are deploying while the backup is still dumping the database.
The docs’ advice: if your deploy must wait for a completed backup, poll /backup/progress until it reports completion. They add a detail that matters: polling also drives the job forward.
Why polling helps
Snapshotify does its work in ticks, short bursts of roughly twenty seconds, each saving its progress before ending. A backup moves through stages (initialize, dump the database, scan files, archive them, finalize), and three things drive it: loopback requests the site makes to itself, a cron watchdog that re-arms roughly every minute, and progress polling from the admin screen. Your script’s polling joins that list.
That is useful on hosts that block loopback requests, which the how-it-works guide says many hosts and nearly every local development environment do. On those hosts a backup progresses slowly via the watchdog, and steady polling from your pipeline keeps it moving.
A polling loop that does not hang forever
The documentation does not publish the response format of the progress endpoint, and it describes the API as internal, so do not hardcode a field name from memory. Run the create and progress calls once by hand on a staging site, look at what comes back (including whether progress wants the ID that create returned), and write your completion check against that. The structure of the loop looks like this:
#!/usr/bin/env bash
set -euo pipefail
SITE="https://example.com/wp-json/snapshotify/v1"
AUTH="deploy:${SNAPSHOTIFY_APP_PASSWORD}"
# Write this against the progress response you saw on staging.
backup_is_complete() {
echo "$1" | grep -q "REPLACE_WITH_YOUR_COMPLETION_MARKER"
}
CREATED=$(curl -sf -X POST "$SITE/backup/create" -u "$AUTH" \
-H "Content-Type: application/json" \
-d '{"title": "Pre-deploy '"${GITHUB_SHA:-manual}"'", "exclusions": ["excludeCore"], "location": "google-drive"}')
echo "$CREATED" # contains the new backup ID
for i in $(seq 1 90); do
STATUS=$(curl -sf "$SITE/backup/progress" -u "$AUTH")
echo "$STATUS"
if backup_is_complete "$STATUS"; then exit 0; fi
sleep 20
done
echo "Backup did not finish in time. Not deploying." >&2
exit 1
Two design choices in that sketch are worth keeping whatever your check looks like:
- A hard time limit. Ninety polls at twenty seconds is half an hour. Pick a number that fits your site, and fail the pipeline when it is exceeded.
- Fail closed. If the backup did not finish, the release does not go out. The whole point of the step is that you never deploy without a fresh restore point.
Step four: check where the archive landed
An upload failure never fails a Snapshotify backup. The cloud storage guide explains that the archive completes as a local backup and the reason is written to that backup’s activity log. You end up with a working backup in the wrong place rather than no backup at all.
That is the right trade, but it means a pipeline that only checks “did it finish?” can miss a broken cloud connection for weeks. Read the backup list or the activity log after the first few runs, and look at the location. A row showing Local on a site configured for cloud storage is telling you the upload failed. The /backup/logs endpoint is where the fallback reason is recorded.
Step five: deploy, then purge
Once the backup is complete, run your release. If you also use Lightify for caching, its REST API has a matching endpoint for the other end of the pipeline, purging and warming the cache after the deploy, with the same application password approach:
curl -X POST https://example.com/wp-json/lightify/v1/purge-everything-and-preload \
-u "deploy:xxxx xxxx xxxx xxxx xxxx xxxx"
Backup, wait, deploy, purge. Four steps, all from the pipeline, none depending on someone remembering.
Things to know before you rely on it
Notifications. If email notifications are on, a backup started by your pipeline behaves like any other: completion and failure emails go to the configured address. Cancelled jobs never send one. The notifications guide recommends keeping Backup failed enabled at minimum, and sending it somewhere a person reads.
Retention. Retention is a Pro setting that keeps only the newest backups and deletes older ones permanently, three by default. If you deploy several times a day, watch your backup list for the first week to see how pre-deploy backups and scheduled ones share that count, and raise Keep Latest Backups if your history is getting shorter than you want. The docs’ advice applies doubly here: keep more than feels necessary.
Disk space. By default a local copy is kept after a successful cloud upload. That is safer, and it uses disk. Developers can change it with the snapshotify_keep_local_copy filter, at the cost of having only one copy.
Restores stay manual. There is a /restore/start endpoint, and the docs describe it as destructive with no undo. From the database step onward the site is in maintenance mode and is being replaced. Automate the backup. Keep the restore a human decision.
What is never in an archive. Some files are always excluded: wp-config.php, server config files such as .user.ini, drop-ins like object-cache.php, caches, node_modules, .git, and .svn. Every archive always contains database.sql and manifest.json, plus whatever you did not exclude.
Free and Pro for this workflow
- Free: manual backups (full site or with exclusions) to local storage, restore from your backup list or an uploaded archive, migration with URL rewriting, downloads, the per-backup activity log, and email notifications.
- Pro: scheduled backups, per-schedule exclusions, retention by count, and Google Drive, OneDrive, and Dropbox storage.
A pre-deploy backup that stays on the same server protects you from a bad release but not from losing the server, which is why most teams pair this with cloud storage. Pro is sold as the DaftPlug membership, so one license unlocks Snapshotify with Progressify, Lightify, Generatify, and Rankify, and plans differ only in the number of sites. See the pricing page for plans and the 14-day money-back guarantee.
For the manual version of the same idea, our guide to taking a database-only WordPress backup before a plugin update covers when a lighter backup is enough.
Quick checklist
- Create a dedicated administrator user for automation.
- Generate an application password and store it as a CI secret.
- Connect cloud storage on the site if you want the backup off the server.
- Call
/backup/createwith a descriptive title and the right exclusions. - Poll
/backup/progresswith a time limit, and fail closed. - Check the location and activity log on the first few runs.
- Deploy, then purge the cache.
- Keep restores manual.
The best backup is the one taken one minute before the change that broke things. Put it in the pipeline, and it will be.


