Restore your PostgreSQL database to a precise moment, or from a pg_dump, from your AI agent
A failed migration, a table emptied by mistake: your database goes back to the moment before, with a simple request to your AI agent. A safety backup is taken first, and in production, nothing happens without your approval.
By Aloïs Oddon, co-founder of Nextmap. Facts checked on November 2, 2026.
Prerequisites
- An app deployed on while, with its PostgreSQL database.
- Your AI agent, connected to while over MCP.
Step 1: Tell your agent where to go back to
You, to your agent: Restore the database to yesterday at 6 pm.
Your agent prepares the restore, to the moment you asked for, and gives you a link.
Step 2: Approve
You open the link and approve, or an administrator does, depending on your permissions. A safety backup is taken first, then the restored database takes the place of the old one.
What your agent does
Your database archives its write-ahead log continuously and takes a full backup every day, with nothing for you to declare: that’s what lets it go back to a precise moment1. Your agent picks the point to go back to, a backup or a moment, within the 14 days they are kept. The restored database is created separately, then takes the place of the old one: nothing is overwritten before you approve.
Check that a backup really works
You, to your agent: Take a backup and check it.
Your agent starts a backup, followed right away by a test: a throwaway database is created from it, and its tables are read back.
Import a pg_dump export
You, to your agent: Import our Heroku export into the database.
Your agent uploads the export, then loads it into your database with pg_restore, separately from your app2.
Find the rows involved before you go back
You, to your agent: Show me the orders deleted since yesterday.
Your agent reads your database in SQL over MCP, with your permissions on the data and without being able to write to it, and shows you the rows involved before you choose the moment.
Go back to the previous version
You, to your agent: Go back to the previous version.
In the 30 minutes after a deployment, the previous version comes back in a second. After that, it takes a few seconds. Once the previous version is back, your agent reads what broke in while’s logs, fixes it and deploys again.
In the docs: PostgreSQL databases, Tested backups and Versions and rollback.
Next steps
Sources
- PostgreSQL, continuous archiving and point-in-time recovery, accessed November 2, 2026
- PostgreSQL, the pg_restore command, accessed November 2, 2026