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 5.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.
Synopsis
gprestore -timestamp YYYYMMDDHHMMSS [-backupdir directory] [-createdb] [-debug] [-globals] [-include-schema schema_name] [-include-table-file file_name] [-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 1 connection, 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.
- -include-schema schema_name
- Optional. Specifies a database schema to restore. You can specify this option multiple times to include multiple schemas. If you specify this option, any schemas that you specify must be available in the backup set. Any schemas that are not included in subsequent -include-schema options are omitted from the restore operation.
- Schemas that you specify for inclusion must not be present in the database when you execute gprestore. You cannot use this option if the backup set uses a single data file for all tables on each segment (gpbackup -single-data-file option), or if objects in the backup set have dependencies on multiple schemas.
- See Filtering the Contents of a Backup or Restore for more information.
- -include-table-file file_name
- Optional. Specifies a text file containing a list of tables to restore. Each line in the text file must define a single table using the format <schema-name>.<table-name>. The file must not include trailing lines. If a table or schema name uses any character other than a lowercase letter, number, or an underscore character, then you must include that name in double quotes. Any tables not listed in this file are omitted from the restore operation.
- If you use the -include-table-file option, gprestore does not restore indexes, create roles, or set the owner of the tables.
- See Filtering the Contents of a Backup or Restore for more information.
- -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.Note: If you used the gpbackup -single-data-file option to combine table backups into a single file per segment, you cannot perform a parallel restore operation with gprestore.
- -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
$ 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
$ dropdb demo $ gprestore -include-schema wikipedia /home/gpadmin/backups/ -timestamp 20171103153156 -createdb