gprestore

A newer version of this documentation is available. Use the version menu above to view the most up-to-date release of the Greenplum 4.x documentation.

gprestore

Restore a Greenplum Database backup that was created using the gpbackup utility. By default gprestore uses backed up metadata files and DDL files located in the Greenplum Database master host data directory, with table data stored locally on segment hosts in CSV data files.

Note: gpbackup and gprestore are experimental utilities and are not intended for use in a production environment. Experimental features are subject to change without notice in future releases.

Synopsis

gprestore -timestamp YYYYMMDDHHMMSS
   [-backupdir directory]
   [-createdb]
   [-debug]
   [-globals]
   [-jobs int]
   [-quiet]
   [-redirect database_name]
   [-verbose]
   [-version]
   [-with-stats]

Description

To use gprestore to restore from a backup set, you must include the -timestamp option to specify the exact timestamp value (YYYYMMDDHHMMSS) of the backup set to restore. If you specified a custom -backupdir to consolidate the backup files, include the same -backupdir option with gprestore to locate the backup files.

Include the -createdb option if the database does not exist in the cluster. You can optionally restore a backup set to a different database by using the -redirect option.

Database objects to be restored must not exist in the target database. If the database itself is not available in Greenplum Database, include the -createdb option to create it with gprestore.

Greenplum Database system objects are automatically included in a gpbackup backup set, but these objects are only restored if you include the -globals option to gprestore. Similarly, if you backed up query plan statistics using the -with-stats option, you can restore those statistics by providing -with-stats to gprestore. By default, only database objects in the backup set are restored.

Performance of restore operations can be improved by creating multiple parallel connections to restore table data. By default gprestore uses 2 parallel connections, but you can increase this number with the the -jobs option for large restore operations.

gprestore does not currently support filtering the database objects that are restored from a backup set.

Options

-timestamp YYYYMMDDHHMMSS
Required. Specifies the timestamp of the gpbackup backup set to restore. By default gprestore tries to locate metadata files for the timestamp on the Greenplum Database master host in the $MASTER_DATA_DIRECTORY/backups/YYYYMMDD/YYYYMMDDhhmmss/ directory, and CSV data files in the <seg_dir>/backups/YYYYMMDD/YYYYMMDDhhmmss/ directory of each segment host.
-backupdir directory
Optional. Sources all backup files (metadata files and data files) from the specified directory. You must specify directory as an absolute path (not relative). If you do not supply this option, gprestore tries to locate metadata files for the timestamp on the Greenplum Database master host in the $MASTER_DATA_DIRECTORY/backups/YYYYMMDD/YYYYMMDDhhmmss/ directory. CSV data files must be available on each segment in the <seg_dir>/backups/YYYYMMDD/YYYYMMDDhhmmss/ directory. Include this option when you specify a custom backup directory with gpbackup.
-createdb
Optional. Creates the database before restoring the database object metadata.
-debug
Optional. Displays verbose debug messages during operation.
-globals
Optional. Restores Greenplum Database system objects in the backup set, in addition to database objects. See Objects Included in a Backup or Restore.
-jobs int
Optional. Specifies the number of parallel connections to use when restoring table data. By default, gprestore uses 1 connection. Increasing this number can improve the speed of restoring data.
-quiet
Optional. Suppress all non-warning, non-error log messages.
-redirect database_name
Optional. Restore to the specified database_name instead of to the database that was backed up.
-verbose
Optional. Print verbose log messages.
-version
Optional. Print the version number and exit.
-with-stats
Optional. Restore query plan statistics from the backup set.

Examples

Create the demo database and restore all schemas and tables in the backup set for the indicated timestamp:
$ dropdb demo;
$ gprestore -timestamp 20171103152558 -createdb
Restore the backup set to the "demos" database instead of the "demo" database that was backed up:
$ createdb demo2;
$ gprestore -timestamp 20171103152558 -redirect demo2
Restore global Greenplum Database metadata and query plan statistics in addition to the database objects:
$ gprestore -timestamp 20171103152558 -createdb -globals -with-stats
Restore, using backup files that were created in the /home/gpadmin/backup directory, creating 8 parallel connections:
$ gprestore -backupdir /home/gpadmin/backups/ -timestamp 20171103153156 -createdb -jobs 8

See Also

gpbackup