Skip to content
ErawanACADEMYไทย

Keep it running

Rewind your database within the window your plan keeps

A migration deleted the wrong rows, a script ran twice, someone deleted what they should not have. Going back one version returns only the code. To get the data back you rewind the database, and how far back you can go depends on your plan.

Stuck somewhere? Erawan looks into it for free on Hobby and above.

How far back

On Hobby, a copy of your database is kept every hour for 7 days, and you choose which hour's copy to go back to. On Pro and Max, the database belongs to your app alone and every change is recorded as it happens, so it rewinds to the minute: 7 days back on Pro, 30 on Max.

All of this is for the Postgres database Erawan connects to your app. If you do not have one yet, see Add a Postgres database to your app. How backups are made, and where they are kept, is on the security page.

Think before you rewind

A rewind puts the database back the way it was at the time you choose. Everything written after that is gone, including orders and good data that came in while you were still working out what went wrong. If only a few rows are damaged, having your AI fix just those rows is usually better than rewinding the whole database.

Ask your AI to rewind

Give the app's name and the time you want to go back to. Thai time is fine, but say that it is Thai time, because the system runs on UTC.

Rewind my-app's database to 2 pm today, Thai time.

Your AI first checks that it can reach that point. On Hobby you pick from the hourly copies that exist, so choose one from before the problem. Then your AI asks you to confirm before it goes ahead. While the rewind runs, your app may not be able to use its database for a while.

The data from just before the rewind is kept, so a wrong time can still be put right. The result your AI gets back from the rewind says how.

Databases this cannot rewind

If your app keeps its data in a SQLite file on its disk, it cannot be rewound this way. The app's disk is copied offsite every night, but a copy taken while your app is writing to the file may not open again. The best fix is to move to Postgres. Until you can, schedule VACUUM INTO to run every night before 4 am Thai time, so it writes a complete copy for the nightly backup to take. Scheduling is covered in Run work on a schedule.

The MySQL database that WordPress and WooCommerce use cannot be rewound this way either.

All Erawan Cloud lessons