Pivotal Knowledge Base


gpdbrestore using "--truncate" Option Combined with the "--table-file" and "--redirect" option, truncates the Listed Tables in the Source Database


Pivotal Greenplum Database (GPDB) 4.3.5.x


While restoring from the backup using --truncate option combined with --table-file and --redirect option, the tables listed in the file used by --table-file option are truncated on the source database. The restore completes successfully.


Important parameters involved in the restore command - 

--truncate - Truncate table data before restoring data to the table from the backup. If this option is not specified, existing table data is not removed before data is restored to the table.This option is supported only when restoring a set of tables with the option -T or --table-file.This option is not supported with the -e option.

--table-file - Specify a file that contains a list of table names to restore. The file contains any number of table names, listed one per line.

--redirect database_nameSpecify the name of the database where the data is restored. Specify this option to restore data to a database that is different than the database specified during backup. If database_name does not exist, it is created.

When the --truncate option is specified, a truncate statement is generated for each table listed in the --table-file. When these statements are executed, truncate should be done on tables present in the database where we are redirecting to, instead truncate is done on tables present in the source database.

This has been identified as a bug present in 4.3.5.x.


In this example, we are restoring database 'source' to database 'destination'. The file contains table name 'public.test_a', which is the table we want to truncate.

Before restore operation: 

source=# select count(*) from test_a;
(1 row)

Run restore using the following command:

 gpdbrestore  -t 20160115102202 --truncate --table-file table.list --redirect destination

After the restore operation-

source=# select count(*) from test_a;
 (1 row)


This has been fixed in version 4.3.6.x.

Additional Information

gpdbrestore using --truncate option combined with --table-file option fails with error message "CRITICAL:-gpdbrestore failed."

Read more on gpdbrestore: http://gpdb.docs.pivotal.io/4360/utility_guide/admin_utilities/gpdbrestore.html


Powered by Zendesk