Differences between revisions 2 and 3
Revision 2 as of 2012-02-07 19:17:17
Size: 2239
Editor: localhost
Comment: converted to 1.6 markup
Revision 3 as of 2014-06-06 04:34:04
Size: 2241
Editor: KarlPinc
Comment: Fix code markup
Deletions are marked like this. Additions are marked like this.
Line 12: Line 12:
 {{{$ ssh YOU@papio.biology.duke.edu  {{{
$ ssh YOU@papio.biology.duke.edu

Backing up the database

It is occasionally useful to backup the database content manually.

However, it is probably not useful to backup the entire Babase database. What is desired is to backup just the data stored in the babase schema, or perhaps another schema.

There is a way to backup the entire database from phpPgAdmin, using Export after choosing the database, but I don't believe there's a way to backup just one schema.

This describes how to backup a schema, or a database, by logging into papio.

  • Login to papio
    $ ssh YOU@papio.biology.duke.edu
    YOU@papio.biology.duke.edu's password:
    Last login: Thu Jun 22 14:34:22 2006 from host.example.com
    [YOU@papio ~]$
  • Backup the database
    [YOU@papio ~]$ pg_dump --file YOURBACKUP.custom --host=localhost --format=c --schema=babase --data-only --user YOU babase

This produces a file YOURBACKUP.custom in your current directory. You can transfer this file to your PC and burn it to a CD if desired.

Backup your schema

To backup a different schema, yours for example, alter the --schema argument. The following command will backup your schema.

[YOU@papio ~]$ pg_dump --file YOURBACKUP.custom --host=localhost --format=c --schema=YOU --data-only --user YOU babase

Backup the entire database

To backup the entire database, not just a schema, leave off the --schema argument.

[YOU@papio ~]$ pg_dump --file YOURBACKUP.custom --host=localhost --format=c --data-only --user YOU babase

Backup the test database

To backup a different database, change the name of the database that appears at the end of the command.

[YOU@papio ~]$ pg_dump --file YOURBACKUP.custom --host=localhost --format=c --data-only --user YOU babase_test

Backup for restoring into another database product

You can have the backup be a series of SQL commands that, when run, will restore the data. This is useful if you would like to put the data into a non-PostgreSQL database.

The following command backs up the entire database, including table definitions, and saves it as SQL.

[YOU@papio ~]$ pg_dump --file YOURBACKUP.sql --host=localhost --format=p --user YOU babase

DatabaseBackups (last edited 2014-06-06 04:34:04 by KarlPinc)

Wiki content based upon work supported by the National Science Foundation under Grant Nos. 0323553 and 0323596. Any opinions, findings, conclusions or recommendations expressed in this material are those of the wiki contributor(s) and do not necessarily reflect the views of the National Science Foundation.