Restore specific records which are deleted from production
by Serhan Balcı, Founder
![](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fserver.5e002a1b.jpg&w=3840&q=75)
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.
![](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fimage1.929c65b0.webp&w=3840&q=75)
and after the query is executed we directly export the results into a CSV file.
![](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fimage2.999fd7a9.webp&w=3840&q=75)
after doing that we should have to connect our production database and we will import these exported data into our production database.
![](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fimage3.d5fcdb15.webp&w=3840&q=75)
We must select the “First row is header” option and we must choose the target table correctly.
![](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fimage4.d8cdaabb.webp&w=3840&q=75)
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”
![](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fimage5.ddde37d1.webp&w=3840&q=75)
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.
![](/_next/image?url=%2F_next%2Fstatic%2Fmedia%2Fimage6.a95529e2.webp&w=3840&q=75)
If you see this notification above then you have successfully imported your data into the production database.