Exploring gpdbrestore command

Post date: Jan 11, 2015 6:27:39 PM

Get the syntax

[gpadmin@sachi ~]$ gpdbrestore --help

COMMAND NAME: gpdbrestore

A wrapper utility around gp_restore. Restores a database from a set of dump files generated by gpcrondump.

*****************************************************

SYNOPSIS

*****************************************************

gpdbrestore { -t <timestamp_key> [-L] 

              | -b YYYYMMDD 

              | -R <hostname>:<path_to_dumpset> 

              | -s <database_name> } 

     [-T <schema>.<table> [,...]] [-e] [-G] [-B <parallel_processes>] 

     [-d <master_data_directory>] [-a] [-q] [-l <logfile_directory>] 

     [-v] [-ddboost]

gpdbrestore -? 

gpdbrestore --version

*****************************************************

DESCRIPTION

*****************************************************

gpdbrestore is a wrapper around gp_restore, which provides some convenience and flexibility in restoring from a set of backup files created by gpcrondump. This utility provides the following additional functionality on top of gp_restore:

1. Automatically reconfigures for compression. 

2. Validates the number of dump files are correct (For primary only, mirror only, primary and mirror, or a subset consisting of some mirror and primary segment dump files). 

3. If a failed segment is detected, restores to active segment instances.

4.  Do not need to know the complete timestamp key (-t) of the backup set to restore. 

Additional options are provided to instead give just a date (-b), backup set directory location (-R), or database name (-s) to restore.

5. The -R option allows the ability to restore from a backup set located on a host outside of the Greenplum Database array (archive host). Ensures that the correct dump file goes to the correct segment instance.

6. Identifies the database name automatically from the backup set.

7. Allows you to restore particular tables only (-T option) instead of the entire database. Note that single tables are not automatically dropped or truncated prior to restore.

8. Can restore global objects such as roles and tablespaces (-G option).

9. Detects if the backup set is primary segments only or primary and mirror segments and passes the appropriate options to gp_restore.

10. Allows you to drop the target database before a restore in a single operation. 

Error Reporting

gpdbrestore does not report errors automatically. After the restore is completed, check the report status files to verify that there are no errors. The restore status files are stored in the db_dumps/<date>/ directory by default. 

*****************************************************

OPTIONS

*****************************************************

-a (do not prompt)

 Do not prompt the user for confirmation.

-b YYYYMMDD

 Looks for dump files in the segment data directories on the Greenplum Database array of hosts in db_dumps/YYYYMMDD.

 If --ddboost is specified, the system looks for dump files on the DD Boost host. 

-B <parallel_processes>

 The number of segments to check in parallel for pre/post-restore  validation. If not specified, the utility will start up to 60 parallel processes depending on how many segment instances it needs to restore.

-d <master_data_directory>

 Optional. The master host data directory. If not specified, the value set for $MASTER_DATA_DIRECTORY will be used.

--ddboost

 Use Data Domain DD Boost for this restore, if the --ddboost option was passed when the data was dumped. Before make sure the one-time DD Boost credential setup is completed.

-e (drop target database before restore)

 Drops the target database before doing the restore and then recreates it.

-G (restore global objects)

 Restores global objects such as roles and tablespaces if the global object dump file db_dumps/<date>/gp_global_1_1_<timestamp> is found  in the master data directory.

-l <logfile_directory>

 The directory to write the log file. Defaults to ~/gpAdminLogs.

-L (list tablenames in backup set)

 When used with the -t option, lists the table names that exist in the named backup set and exits. Does not do a restore.

-q (no screen output)

 Run in quiet mode. Command output is not displayed on the screen, but is still written to the log file.

-R <hostname>:<path_to_dumpset>

 Allows you to provide a hostname and full path to a set of dump files. The host does not have to be in the Greenplum Database array of hosts, but must be accessible from the Greenplum master.

-s <database_name>

 Looks for latest set of dump files for the given database name in  the segment data directories db_dumps directory on the Greenplum Database array of hosts.

-t <timestamp_key>

 The 14 digit timestamp key that uniquely identifies a backup set of data to restore. It is of the form YYYYMMDDHHMMSS. Looks for dump files matching this timestamp key in the segment data directories db_dumps directory on the Greenplum Database array of hosts.

-T <schema>.<table_name>

 A comma-separated list of specific table names to restore. The named table(s) must exist in the backup set of the database being restored. Existing tables are not automatically truncated before data is restored from backup. If your intention is to replace existing data in the table from backup, truncate the table prior 

 to running gpdbrestore -T.

-v | --verbose

Specifies verbose mode.

--version (show utility version)

 Displays the version of this utility.

-? (help)

 Displays the online help.

*****************************************************

EXAMPLES

*****************************************************

Example 1: 

Restore the sales database from the latest backup files generated by gpcrondump (assumes backup files are in the segment data directories in db_dumps):

[gpadmin@sachi ~]$gpdbrestore -s sales

Example 2: 

Restore a database from backup files that reside on an archive host outside the Greenplum Database array (command issued on the Greenplum master host):

[gpadmin@sachi ~]$gpdbrestore -R archivehostname:/data_p1/db_dumps/20080214

Example 3:

Restore global objects only (roles and tablespaces):

[gpadmin@sachi ~]$gpdbrestore -G