A newer version of this documentation is available. Use the version menu above to view the most up-to-date release of the Greenplum 5.x documentation.
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.
gprestore -timestamp YYYYMMDDHHMMSS [-backupdir directory] [-createdb] [-debug] [-globals] [-jobs int] [-quiet] [-redirect database_name] [-verbose] [-version] [-with-stats]
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.
- -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.
- Optional. Creates the database before restoring the database object metadata.
- Optional. Displays verbose debug messages during operation.
- 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.
- 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.
- Optional. Print verbose log messages.
- Optional. Print the version number and exit.
- Optional. Restore query plan statistics from the backup set.
$ dropdb demo; $ gprestore -timestamp 20171103152558 -createdb
$ createdb demo2; $ gprestore -timestamp 20171103152558 -redirect demo2
$ gprestore -timestamp 20171103152558 -createdb -globals -with-stats
$ gprestore -backupdir /home/gpadmin/backups/ -timestamp 20171103153156 -createdb -jobs 8