PostgreSQL is undoubtedly one of the most popular and efficient open-source relational database management system powering millions of applications. These days a database backup mechanism is essential for any project onboard. Luckily PostgreSQL comes with built-in utilities for creating and restoring backups to make our life simpler. Backup and Restore Databases in PostgreSQL PostgreSQL allows a great degree of flexibility for backup and restoration of data, In this article one by one we will go through the most used utilities. Backing up a database in a tar file The pg_dump utility is used for backing up data of a single database or table in PostgreSQL. pg_dump -U db_user -W -F t db_name > /path/to/your/file/dump_name.tar Here we used the following options: -W will force pg_dump to prompt for a password before connecting to the server. -F is used to specify the format of the output file, which can be one of the following: p – plain-text SQL script c – custom-format archive d – directory-format archive t – tar-format archive In case you encounter the following error. pg_dump: [archiver (db)] connection to database "mydb" failed: FATAL: Peer …
The post How To Backup and Restore Data in PostgreSQL Database appeared first on Django Central.
from Planet Python
via read more
No comments:
Post a Comment