To restore a PostgreSQL database, you can use the psql or pg_restore utilities. You can restore the dump using psql as shown. To back up all PostgreSQL databases, use the pg_dumpall tool as shown. $ pg_dump -F d tecmintdb -f tecmintdumpdir The directory which will be created by pg_dump must not exist. To dump output in the directory output format, use the -f flag (which is used to specify the output file) to specify the target directory instead of a file. You can specify the output format using the -F option, where c means custom format archive file, d means directory format archive, and t means tar format archive file: all formats are suitable for input into pg_restore.įor example: $ pg_dump -F c tecmintdb > tecmintdb.dump The pg_dump supports other output formats as well. By default, the output format is a plain-text SQL script file. To back up, a PostgreSQL database, start by logging into your database server, then switch to the Postgres user account, and run pg_dump as follows (replace tecmintdb with the name of the database you want to backup). It generates a database file with SQL commands in a format that can be easily restored in the future. PostgreSQL provides the pg_dump utility to help you back up databases. Let’s get started… Backup a Single PostgreSQL Database How to Install PostgreSQL and pgAdmin in RHEL 8.How to Install PostgreSQL and pgAdmin in CentOS 8.How to Install PostgreSQL and pgAdmin4 in Ubuntu 20.04.If not, read our following articles to install PostgreSQL on your Linux distribution. We assume that you already have a working installation of the PostgreSQL database system. In this article, you will learn how to backup and restore a PostgreSQL database. In a production environment, no matter how large or small your PostgreSQL database may be, regular back is an essential aspect of database management.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |