Rate This Document
Findability
Accuracy
Completeness
Readability

Backing Up the Database

To prevent data loss, you are advised to back up the database data before uninstalling the database. Perform backups as required.

Backing Up the Database

  1. Log in to the database as the gpadmin user.
    1
    su - gpadmin
    
  2. Back up databases.
    • Back up a single database. In the following command, databasename indicates the name of the database to be backed up, which must exist in the database. databasename.dump is the name of the backup file. By default, the backup file is stored in the current directory.
      1
      pg_dump -Fc databasename > databasename.dump
      
    • Back up all databases. In the following command, all.dump indicates the name of the backup file. By default, the file is stored in the current directory.
      1
      pg_dumpall >all.dump
      

Restoring the Database

  1. Log in to the database as the gpadmin user.
    1
    su - gpadmin
    
  2. Restore databases.
    • Restore a single database. In the following command, databasename indicates the name of the database to be restored, which must exist in the database. databasename.dump is the file used for restoration. The file path may vary.
      1
      pg_restore -d databasename databasename.dump
      
    • Restore all databases. In the following command, all.dump is the file used for restoration. The file path may vary.
      psql -f all.dump postgres