Database Backup/Restore

The most critical component of any database maintenance plan is the database backup and restore procedures. Once again, PostgreSQL makes the administrator’s job easier by providing command-line tools such as pg_dump, pg_dumpall, and pg_restore. Like commands such as vacuumdb, these are especially suited to be run as cron jobs.

By default, pg_dump and pg_dumpall simply dump all output to stdout. However, this can easily be redirected to files using the appropriate UNIX redirection symbols.

>pg_dump newriders > nr.backup 

After the command has redirected its output to a standard OS file, standard backup tools can be used to securely archive it.

Here are some factors to consider when trying to evaluate an optimal backup ...

Get PostgreSQL Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.