postgresqlHow do I create a backup of my PostgreSQL database?
Creating a backup of a PostgreSQL database is done using the pg_dump
command. This command will create a backup file of the specified database.
Example
$ pg_dump mydb > db_backup.sql
This will create a backup of the mydb
database in the file db_backup.sql
.
The pg_dump
command has several options to customize the output of the backup file. For example, the -F
option can be used to specify the format of the output file, such as -Fc
for a custom format or -Fp
for a plain-text SQL file.
Code explanation
pg_dump
: The command used to create the backup.mydb
: The name of the database to be backed up.db_backup.sql
: The file that the backup will be saved to.-F
: Option to specify the format of the output file.
Helpful links
More of Postgresql
- How can I troubleshoot zero damaged pages in PostgreSQL?
- How do I use PostgreSQL ZonedDateTime to store date and time information?
- How can I use PostgreSQL with YAML?
- How can I use PostgreSQL XOR to compare two values?
- How do I use PostgreSQL's XMLTABLE to parse XML data?
- How do I parse XML data using PostgreSQL?
- How do I set the PostgreSQL work_mem parameter?
- How do I use a PostgreSQL XML parser in an example?
- How can I convert XML data to a PostgreSQL table?
- How do I set up a web interface for PostgreSQL?
See more codes...