Snapshots & Restore
Forge Pro captures the "before" state automatically so a bad write can be undone.
| Write | What is captured | Restore with |
|---|---|---|
Database write (wp_db_write) | The entire target table | wp_restore_snapshot |
| File write, delete, move, promote | The previous content of the path | wp_restore_file |
| Content block edit | Handled by WordPress post revisions | The post's revision history |
wp_execute_php | Nothing | Your own backup |
⚠️
Raw PHP has no generic "before" state, which is why wp_execute_php requires you to acknowledge that a real backup is in place. Snapshots are a safety net, not a replacement for backups.
Database Snapshots
- The AI must name the table it will affect (with prefix, for example
wp_options). The whole table is copied first. - Tables with more than 5,000 rows are refused, because they cannot be fully snapshotted. Take a manual backup for those.
wp_restore_snapshotrestores a specific snapshot ID, or the most recent unrestored one if none is given.
File Snapshots
Writes to a live path, deletes, moves, and promoted drafts save the prior content. wp_restore_file reverts one.
Finding Snapshots
From the AI
wp_list_snapshots lists recent file and database snapshot IDs.
From a terminal
wp forge snapshots
wp forge snapshots --limit=25Confirm Before Restoring
Restoring a table replaces its current contents with the snapshot. Rows written after the snapshot are lost. Review the table with wp_db_read first.