![]() To minimize the risk of data loss, you need to back up your databases to preserve modifications to your data on a regular basis. ![]() A well-planned backup and restore strategy helps protect databases against data loss. Test your strategy by restoring a set of backups and then recovering your database. Pg_dump is a utility for backing up a PostgreSQL database. It makes consistent backups even if the database is being used concurrently. pg_dump does not block other users accessing the database (readers or writers). You can use the pg_dump command line program, or you can use phpPgAdmin to backup a PostgreSQL database to a file.Īccess the command line on the computer where the database is stored. If you have physical access to the computer, you can open a DOS or terminal window to access the command line. Syntax: pg_dump -U USERNAME DBNAME > Mybackup.pgsql Replace USERNAME with your username, and DBNAME with the name of the database that you want to export: Type the following command, and then press ENTER. Type your password at the Password prompt. If the Mybackup.pgsql file is on a remote computer, download the file to your local computer.Ĭomplete syntax and other options of pg_dump The Mybackup.pgsql file now contains all of the data for the DBNAME database. Syntax: pg_dump ĭump only the data (table data, large objects, and sequence values), not the schema (data definitions) Tableplus run function download# ![]() This option is similar to, but for historical reasons not identical to, specifying -section=data. Include large objects in the dump (default behavior). Output commands to clean (drop) database objects prior to outputting the commands for creating them. This option is only meaningful for the plain-text format.īegin the output with a command to create the database itself and reconnect to the created database.Ĭreate the dump in the specified character set encoding (default, database encoding). P plain : Output a plain-text SQL script file (the default).Ĭ custom : Output a custom-format archive suitable for input into pg_restore.ĭ directory : Output a directory-format archive suitable for input into pg_restore. T tar : Output a tar-format archive suitable for input into pg_restore. Run the dump in parallel by dumping njobs tables simultaneously.ĭump only schemas matching schema this selects both the schema itself, and all its contained objects. When this option is not specified, all non-system schemas in the target database will be dumped.ĭo not dump any schemas matching the schema pattern. When both -n and -N are given, the behavior is to dump just the schemas that match at least one -n switch but no -N switches. If -N appears without -n, then schemas matching -N are excluded from what is otherwise a normal dump.ĭump object identifiers (OIDs) as part of the data for every table.ĭo not output commands to set ownership of objects to match the original database. This option is only meaningful for the plain-text format. Tableplus run function archive#įor the archive formats, you can specify the option when you call pg_restore. This option is obsolete but still accepted for backward compatibility.ĭump only the object definitions (schema), not data. ![]() Specify the superuser user name to use when disabling triggers. This is relevant only if -disable-triggers is used.ĭump only tables (or views or sequences or foreign tables) matching table. Multiple tables can be selected by writing multiple -t switches.ĭo not dump any tables matching the table pattern. When both -t and -T are given, the behavior is to dump just the tables that match at least one -t switch but no -T switches.
0 Comments
Leave a Reply. |