I'm using pgAdmin to restore PostgreSQL database. To restore the database I need to delete, drop and remake it. How to restore the database without deleting and remaking it?
This cannot be done in pgAdmin or with any database tools . Regular backup files cannot be restored without deleting the data first because they consist of normal COPY
statements which will fail if you have rows in the database (primary keys collide etc).
For a simple way to get back to an earlier snapshot in a testing environment take a look at PostgreSQL documentation - 24.2. File System Level Backup :
For backup:
For restore:
Note:
Also with regular backups you don't have to do a DROP TABLE
if you do a data-only restore with pg_restore --data-only
for example. You still have to delete the data though.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.