Fixes › Database / Supabase RLS
Replit rollback did not bring my data back: how to restore the development or production database
Published
The error
I rolled back to a Replit Agent checkpoint and the code is old again but the data is still wrong / rows the Agent deleted are still missing / my published app's live data did not change after Rollback to here / a Publish dropped a column or table and the data is gone
Why it happens
A Replit checkpoint can capture your files, Agent memory and your development database, but a rollback does not automatically restore everything. Replit's Checkpoints and Rollbacks guide says that by default rollbacks do not change your database: to include the development database you have to select Database under Additional rollback options before confirming. More importantly, checkpoint rollback never touches your production database, the separate database your published app uses. Production data has its own recovery tools: point-in-time recovery (PITR), on by default with a 7-day window (up to 28 days on Pro, Teams and Enterprise), and optional scheduled daily backups. Replit also says restoring the database does not change your code and rolling back code does not change production data, so people often roll back the code, republish, and find the live data still broken. A common cause of lost production data is the Publish step itself: when you publish, Replit applies your development schema changes to production, and answering 'No, create new column' to a rename question drops the old column with its data. If your app uses an external database such as Supabase, Replit's rollback and publish do not manage it, so you need that provider's backups.
How to fix it
- Stop making changes first. Do not ask the Agent to 'fix the data', do not publish again and do not run new migrations until you know which database lost data and when. Every extra write makes the restore point harder to pick.
- Work out which database is wrong. In the Database tool, check whether the missing rows are in the Development database (what the Project Editor and Agent use) or the Production database (what your published app uses). Both use a variable called DATABASE_URL, but each environment has its own value, so the published app reads production even when the editor shows dev data.
- Note the exact time the damage happened, in your local time zone: the Agent message that ran the change, or the publish that applied it. You need this to pick a checkpoint or a PITR timestamp before the damage.
- Development database: open the Agent tab, find the checkpoint from just before the bad change, choose Rollback to here, and before confirming select Database under Additional rollback options. Read the confirmation dialog: it should list your development database as well as files and Agent memory. Replit keeps development database history for Agent checkpoints up to 7 days back. This also removes all code changes made after that checkpoint.
- Production database: checkpoint rollback will never fix it. Before restoring, export what you have now (My Data, table menu, Export all to .csv/.json/.xlsx, or ask the Agent to export every table to CSV with its read-only production access), so data written since the incident is not lost.
- Then restore production with point-in-time recovery: Database tool, select Production, Settings, expand Point-in-time recovery under Advanced, select Restore database..., enter a timestamp just before the damage (your local time zone, inside the recovery window) and select Restore. The restore replaces live data. You can restore to an earlier point afterwards but not forward, so check the time carefully.
- If PITR is disabled or the moment is outside the window, check Scheduled backups (Settings, Scheduled backups under Advanced, View all backups, Restore). They are off by default and available on Core and higher plans. If neither exists, use your exports or contact Replit Support.
- Line code and data up again. Restoring the database does not change your code. If the bad code caused the problem, roll back to the matching checkpoint (without the dev Database option if dev data is fine) and publish again, so the live app and its data come from the same moment.
- Re-add any real user data written after the restore point from the export you took, for example orders or sign-ups. Check payments against Stripe or your payment provider, which keeps its own records.
- Prevent it next time: read the Generated migrations SQL in the Publish pane before every publish, answer 'Yes, rename column' when a column or table was really renamed, treat an orange data-loss warning as a stop sign, consider a longer PITR window or scheduled backups for real user data, and if you use Supabase or another external database, turn on that provider's backups.
Fix prompt (paste into Lovable, Bolt, Cursor, Replit or v0)
My Replit app lost data. What happened: <DESCRIBE, e.g. Agent deleted rows / Publish dropped a column>. Approximate time: <TIME and time zone>. Do not change any data, do not write migrations and do not publish. 1) Tell me which database my published app uses and whether the missing data was in the development or production database, using your read-only production access. 2) List the Agent checkpoints and publishes around that time and say which one most likely caused the loss. 3) Export every production table to CSV in an exports folder (add it to .gitignore) and tell me the row counts. 4) Tell me step by step whether I should use checkpoint rollback with the Database option (development) or point-in-time recovery (production), and the exact timestamp to restore to. 5) List any data written after that timestamp that I will need to re-add.
Error codes this fixes
Detected potential conflicts, please review(Replit Publish)Development database changes detected(Replit Publish)
FAQ
Does a Replit checkpoint rollback restore my database?
Only your development database, and only if you select Database under Additional rollback options before confirming. By default a rollback does not change your database, and it never touches the production database your published app uses.
How do I restore my Replit production database?
Use point-in-time recovery in the Database tool: select Production, open Settings, expand Point-in-time recovery under Advanced, select Restore database... and enter a timestamp inside your recovery window. It is on by default with a 7-day window, up to 28 days on Pro, Teams and Enterprise. Scheduled daily backups are a second option if you turned them on.
I rolled back the code and republished. Why is the live data still wrong?
Because rolling back code does not change production data. Restore the production database to a point before the damage, then roll back to the matching checkpoint and publish again.
Can the Replit Agent delete my production data?
Replit says the Agent cannot modify the production database; it reads it through a read-only replica. Production data usually changes through your app, through manual edits with Enable Editing on, or when Publish applies development schema changes, such as dropping a column that was really renamed.
My Replit app uses Supabase. Will a rollback restore it?
No. Replit's rollback and publish only manage Replit's own development and production databases. An external database such as Supabase has to be restored with that provider's backup tools.
Sources
Based on the official documentation:
- Replit: Checkpoints and Rollbacks
- Replit: Data recovery (checkpoints, point-in-time recovery, scheduled backups)
- Replit: Development and production databases
- Replit: How Publish updates your production database
- Replit: Work with your data (export your production database)
Related fixes
- Environment variable is undefined in production
- App works on localhost but breaks in production: a checklist to find the cause
- Replit deploy: app not reachable / port not open
- AI "fixed" my Supabase error by disabling RLS or using the service_role key: how to undo it safely
- Supabase update says saved but the change is gone after refresh
- Replit app shows 502 Bad Gateway after republishing (or publish fails at the last step)
Get one new fix a week
Free newsletter: the newest breakages in Lovable, Bolt, Cursor, Replit and v0 apps, with paste-in fixes.
We only use your email to send the newsletter. Unsubscribe any time. See privacy.