Backup and restore PostGres database with pgAdmin 4
1. The goal of the lesson
No ADS
In this lesson, I will show you how to backup and restore the PostGreSQL database using the pgAdmin tool.
Backup
Backup is copying data in your database, and putting it in a safe place in order to prevent the case where the database is broken for some reason, for example, the hard drive of server is broken. Backup can help you restore data.
There are basically 2 types of backups:
- Physical backups
- Logical backups
Physical backups: Your database is installed on a server. Its data is stored on files. Therefore, to back it up, you only need to copy all these files and put them in a safe location (Probably another hard drive).
Logical backups: This is a way for you to copy part of data, through a tool provided by the database you are using. For example, you want to back up the data of several tables, or some Schemas. The obtained result is one or several files.
Restore
Restore: an use of "product" that you obtain upon backup to restore data for database.
2. Backup
No ADS
Suppose that now I have a mytestdb database, I will use pgAdmin to back up this database.
There are many types of formats when you back up, such as Custom, Tar, Directory, Plain. But the Custom format is the most popular. The result is that you will get a file with the extension such as backup.
OK, select Custom format, select a location, and the file name to be created ...
After the successful backup process, you will get a file:
3. Restore
No ADS
In the above step, you have backed up a database and get a file, you can use this file to restore the database as necessary.
To restore, on the pgAdmin, create a empty database.
For example, I create a database with the name: mytestdb2.
The mytestdb2 database is created. it is really an empty database. it does not cover tables or any other objects.
Use the Restore function to restore this database from the file wthich you have backed up.
Successful Restore process:
No ADS