Skip to main content
Cookbook Maintenance JetBackup

Get a Fresh JetBackup Backup Before an Update with AI

A recent full JetBackup backup that covers the change, found or taken on your click and followed to the end, before the AI touches a plugin, theme or WordPress.

Difficulty Beginner
Time ~30 min

Prerequisites

A site connected to WPVibe as an administrator (a network administrator on multisite), running JetBackup (tested on the free 3.1.24.10) on WordPress 6.9 or newer, with JetBackup, Settings, Security, WordPress Abilities API turned on (it is off by default). A job that backs up both files and database without leaving out the plugins or themes folder, and free disk space for about three times a full backup.

The prompt
My site uses JetBackup. Before I ask you to [the change, for example update WooCommerce and my theme], make sure I have a fresh full backup that covers it. You cannot start a backup yourself: when one is needed, ask me to start it in JetBackup.

1. Run discover_abilities with category jetbackup. If no jetbackup abilities are listed, stop and tell me to install or update the free JetBackup plugin (on WordPress 6.9 or newer) and turn on JetBackup, Settings, Security, WordPress Abilities API, which is off by default. If a jetbackup ability answers that I am not allowed, tell me WPVibe must be connected as an administrator (a network administrator on multisite), and that if JetBackup's two-factor login (MFA) is on, Allow Abilities API Access When MFA is Enabled must be on too, on the same tab. Then stop.
2. JetBackup answers in numbers. A backup's contains and a job's backup_contains: 1 is site files only, 2 is the database only, 3 is both (a full backup). A job's excludes are folders it leaves out and its database_excludes are database tables whose rows it leaves out. On top of those, JetBackup leaves out common clutter by default (Settings, Performance, Use Common Folder Excludes): caches, log files, other backup plugins' folders, and the rows of log, session and statistics tables of some common plugins (their structure is kept): WooCommerce sessions and logs, Action Scheduler logs, Yoast's link tables, Wordfence and Shield security logs, Activity Log, WP Activity Log and Simple History, WP Statistics, Redirection's logs, WPML's mails and UpdraftPlus job data, more than the list on that screen shows (Use Common Database Excludes); this does not show in a job's fields and it is mostly caches, logs and other backup plugins' folders (it also leaves out some cache plugins' config folders, such as wp-content/wp-rocket-config). A backup also never includes JetBackup's own plugin folder, so it does not cover updating JetBackup itself, and by default it leaves out another WordPress install nested inside the site (Excluded Nested WordPress Sites, same tab, one folder deep). A backup queue item whose job_id is not in list-backup-jobs belongs to a deleted job or to JetBackup's internal configuration job. A backup's schedules_names say how it was made: Manually means Run Now; Imported means it was brought in from elsewhere; Hourly, Daily, Weekly, Monthly or After Job Done is the kind of schedule that made it. Leave out imported backups (params.imported true, or Imported in schedules_names). Compare each backup's params.site_url with run_wp_cli option get siteurl, ignoring http, https and www: leave out backups made under another address, but list them by that address (a domain change or host move can be the reason) instead of hiding them. Leave out any backup whose deleted is not 0: JetBackup has marked it for removal. In the queue, type 1 is a backup; status below 100 means waiting or running, 100 completed, 101 partially completed, 102 failed, 103 aborted, 104 never finished. status_name is often empty, so go by the number. Backups do not say which job made them: a queue item's item_data.snapshot_name is the name of the backup it made and item_data.job_id its job, and the queue keeps finished items for 24 hours by default (JetBackup, Settings, Maintenance). Times (created, started, ended, last_run, next_run) are Unix timestamps: get the time now with run_wp_cli db query "SELECT UNIX_TIMESTAMP() AS now", and show me times in my site's time zone (run_wp_cli option get timezone_string, or option get gmt_offset when that is empty).
3. Run jetbackup/list-backups and jetbackup/list-queue-items. JetBackup's lists come back in no fixed order, up to 50 at a time: run each with limit 25 and, while you have fewer items than total, again with skip set to how many you have. If a page adds no new _id, stop paging and say how many you have of total. If WPVibe says a result was cut, run that page again with a smaller limit and keep paging: these abilities only read, so running them again is safe. Drop duplicates by _id, say so if you still have fewer than total, and sort backups and queue items by created yourself. Note the highest queue _id (0 if there are none). Take each backup with contains 3 made less than [how recent it must be, for example 1 hour] ago, newest first, and check them in turn as follows. Find the queue item whose item_data.snapshot_name is its name. Count the backup only if that item's status is 100: for 101, tell me which destination is missing or that errors were logged, and treat it as in step 7's 101 rule. Run jetbackup/get-backup-job with that item's item_data.job_id. The backup covers the change only if that job's excludes leave out none of wp-content/plugins, wp-content/themes or anything else the change touches, and its database_excludes leave out no table the change touches (a WooCommerce update touches the woocommerce and wc tables, for example). The rows JetBackup leaves out by default (above) are logs, sessions, caches and statistics that a rollback does not need: mention them once if the change touches one of those plugins, and still count the backup as covering the change. If I want those rows too, tell me to turn off Use Common Database Excludes in JetBackup, Settings, Performance before the backup runs. As soon as one covers it, tell me its time, size, where it is and what its job leaves out, say I am covered, and go to step 8. If none does, say why (no such backup, not traceable to its job, or its job leaves out what the change touches) and go on.
4. Run jetbackup/list-backup-jobs the same way. Pick the enabled job with backup_contains 3 whose excludes and database_excludes leave out the least, and tell me what they leave out (wp-content/uploads means no images or other media). Run jetbackup/list-destinations the same way: if any destination that job uses has a type other than Local or JetStorage, warn me that without a premium license the free plugin aborts the whole backup. If there is no such job, or it leaves out wp-content/plugins, wp-content/themes or tables the change touches, tell me its backup would not cover the change and to create or edit a job in JetBackup, Backup Jobs, backing up both files and database, and stop.
5. If a backup (type 1) in the queue is waiting or running: if it is that job's, tell me, run step 6's system check, and then follow it as in step 7 instead of asking for another; if it is another job's, tell me which and its progress.message, and ask whether to wait for it to end before starting mine.
6. Run jetbackup/get-system-info. If system_checks heartbeat or cron is false, tell me an open admin page will not move JetBackup's queue: turn on Backend Heartbeat and Cron Scheduling in JetBackup, Settings, Automation, or make sure my host runs JetBackup's server cron job, and tell you when that is done. Tell me the size of the newest backup that job made (through the queue, item_data.job_id); if there is none, the largest backup with contains 3 and deleted 0, and say it is only a floor if that backup's job leaves out more than the chosen one (or that you have none to go by). Ask me to make sure the hosting account has at least about three times that much free (a rough floor: the size shown is compressed), since a full disk can take the site down: JetBackup builds the archive uncompressed first, then writes the compressed copy beside it before deleting the original. get-system-info's info.free_disk_space is there only when Show available disk space is on in JetBackup, Settings, General, and it shows the server's disk, not the hosting account's quota: mention it as a hint if it is there. Ask me to check that Cleanup Revisions is off in JetBackup, Settings, Performance (off by default): when it is on, each backup permanently deletes the site's post revisions before dumping the database. Then ask me to open JetBackup, Backup Jobs, click Run Now on that job, and keep a WordPress admin page open as an administrator until you tell me it finished, in its own window rather than a background tab, since browsers slow timers in background tabs. JetBackup does not use WordPress's scheduler (the WordPress Cron switch in its Settings, Automation has no effect in 3.1.24.10). Its queue, scheduled backups and Run Now included, only moves while an administrator (on multisite, a network administrator in the main site's admin) has a WordPress admin page open, or when a server cron job or JetBackup's public cron URL runs it. The open admin page and the public cron URL only move it when Cron Scheduling is on in JetBackup, Settings, Automation, and the admin page also needs Backend Heartbeat on; JetBackup's Cron Command run on the server works either way. Wait until I say I have.
7. Run jetbackup/list-queue-items the same way and find the backup (type 1) with an _id above the one you noted and item_data.job_id of that job, or the item from step 5. If there is none, tell me it was not queued and stop. Then run jetbackup/get-queue-item with its _id once, and tell me progress.message and progress.sub_message (not progress.percentage: it covers the current step, and showed 100 while a full backup still had minutes of archiving left). If it has not ended, tell me where it is, that a full backup of a large site can take many minutes (ours, 1.4 GB, took about 22), and ask me to say check for another look; each time I do, run get-queue-item once more. If it still says Waiting for cron, remind me an administrator's admin page must stay open. If the status is 101, the run finished but reached fewer destinations than the job has or logged an error: look in list-backups for item_data.snapshot_name with contains 3 and deleted 0, tell me where it exists and which destination is missing, and ask me to read the ERROR lines in its log (JetBackup, Queue, open the item, View Log) before we rely on it; do not start the change until I say go after that. If the status is 102 to 104, tell me what it means and progress.message and progress.sub_message, say not to start the change, and tell me the reason is in its log (JetBackup, Queue, open the item, View Log or Download Log), then stop. If it is 100, run jetbackup/list-backups again and confirm a backup whose name is item_data.snapshot_name, with contains 3 and deleted 0; tell me its time, size and where it is.
8. Then stop and wait. Do not begin the change until I reply go.
Already connected?

Skip pasting the full prompt. Drop this into your AI on a site that already has WPVibe:

Run the “Get a Fresh JetBackup Backup Before an Update with AI” recipe from the WPVibe cookbook on my connected site.

Updating a plugin, a theme or WordPress is when sites break, and a backup taken just before is the easy way back. Last night’s backup may be fine, or it may hold only the database, leave out the plugins folder, or be a week old, and checking means clicking through JetBackup.

The AI looks for a recent full backup whose job covers what you are changing. If there isn’t one, it picks the right job, checks JetBackup can run it, and asks you to click Run Now, because the abilities cannot start a backup. It follows the backup in JetBackup’s queue each time you ask, checks the new copy is there, and only then waits for you to say go on the update.

Keep a WordPress admin page open while the backup runs: unless a server cron job runs JetBackup’s queue, it only moves while an administrator has an admin page open. In our test a queued backup waited over two minutes, then ran on the first admin page visit, and a full backup of the test site (1.4 GB) took about 22 minutes. Restoring is done in JetBackup (Backups), not by the AI.

Outcome

A full backup made within your window by a job that covers the change, confirmed in JetBackup, and the AI waiting for your go before the update.