Restore specific records which are deleted from production

Serhan Balcı
3 min readMar 9, 2023

--

Photo by Jandira Sonnendeck on Unsplash

Hello 👋

In this article, we will learn how to restore some data removed from the production database.

Most of the learnings give us the ability to restore the entire database or restore the entire table. But imagine that you deleted some specific records from different tables. For example, you removed two orders from the database according to related records too.

First, we will locate the exact date of data loss. For example ten days ago. So we get the backup on this date and restore that backup in a different database.

Now we have two databases. First is our production database and second, will be our restored database which the deleted records living in this database.

Let’s find the order, I am using Postico to connect our PostgreSQL database.

Postico

and after the query is executed we directly export the results into a CSV file.

Postico

after doing that we should have to connect our production database and we will import these exported data into our production database.

Postico

We must select the “First row is header” option and we must choose the target table correctly.

Postico

Finally, we decide match column strategy. I am selecting the Match columns by name option and Postico says “X of x columns selected for import”

If you have empty columns that you don’t want to import. You can select the “Do not import” option for every column.

after this selection let’s hit the import button and wait with our fingers crossed.

If you see this notification above then you have successfully imported your data into the production database.

--

--

Serhan Balcı
Serhan Balcı

Written by Serhan Balcı

More than 15 years of professional experience & knowledge about software development. In addition to designing software, web applications, and web services.

No responses yet