Greenplum gpdbrestore 全量恢复

来源:互联网 发布:手机淘宝怎么评价卖家 编辑:程序博客网 时间:2024/06/07 15:01
参数介绍:
-a (do not prompt) 
-B <parallel_processes>  并发数
-d <master_data_directory> master目录设置,一般master都会设置这个环境变量
-e 恢复之前是否删除数据库
-G [include|only] 如果是only只恢复global对象
-l 指定日志目录
-m 只恢复元数据
-R <hostname>:<path_to_dumpset> 如果备份文件不在默认路径下,可以使用-R指定恢复的路径
-s 指定数据库名
--truncate  恢复之前删除表的数据,不能与-e共用
-u <backup_directory>  指定备份目录
-t <timestamp_key>导出的时间戳
--restore-stats [include|only]
 Specify "--restore-stats only" to only restore the statistics dump file or
 "--restore-stats include" to restore statistics along with a normal restore.
 If "--restore-stats only" is specified along with the -e option, an error
 to restore. It is of the form YYYYMMDDHHMMSS. Looks for dump files 
 Table names to restore, specify multiple times for multiple tables. 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, truncate the table prior to running gpdbrestore -T. 
 Schema names to restore, specify multiple times for multiple schemas. 
 Existing tables are not automatically truncated before data is restored 
 Specify a file <file_name> that contains a list of table names to restore. 
 before data is restored to the table. This option is supported only

--report-status-dir <report_directory>
 Database host (master and segment hosts) where gpdbrestore writes report 
 status files for a restore operation. If <report_directory> does not exist 
 If this option is not specified and the -u option is specified, report 
 not writable, the report status files are written to segment data 
 If <backup_directory> is not writable, backup operation report status 
 different location where report status files are written with the 
 --report-status-dir option. 

实例:
postgres=# \c  hank hank 
You are now connected to database "hank" as user "hank".
hank=> \dt
                    List of relations
 Schema |        Name        | Type  |  Owner  | Storage 
--------+--------------------+-------+---------+---------
 hank   | tb1                | table | hank    | heap
 hank   | test               | table | hank    | heap
 hank   | test1              | table | hank    | heap
 public | gpcrondump_history | table | gpadmin | heap
(4 rows)

hank=> select count(*) from tb1;
  count   
----------
 10000000
(1 row)

hank=> drop table tb1;
DROP TABLE
hank=> drop table test;
DROP TABLE
hank=> drop table test1;
DROP TABLE

以上模拟故障误删表

做恢复
gpdbrestore -a -e --prefix hank -u /home/gpadmin/backup --restore-stats include --report-status-dir /home/gpadmin/backup -t 20170401151503


20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Starting gpdbrestore with args: -a -e --prefix hank -u /home/gpadmin/backup --restore-stats include --report-status-dir /home/gpadmin/backup -t 20170401151503
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-------------------------------------------
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Greenplum database restore parameters
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-------------------------------------------
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Restore type               = Full Database
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Database to be restored    = hank
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Drop and re-create db      = On
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Restore method             = Restore specific timestamp
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Restore timestamp          = 20170401151503
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Restore compressed dump    = On
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Restore global objects     = Off
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Array fault tolerance      = f
20170405:13:41:38:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-------------------------------------------
20170405:13:41:39:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Dropping Database hank
20170405:13:41:41:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Dropped Database hank
20170405:13:41:41:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Invoking sql file: /home/gpadmin/backup/db_dumps/20170401/hank_gp_cdatabase_-1_1_20170401151503
20170405:13:41:57:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Creating gp_toolkit schema for database "hank"
20170405:13:41:58:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Adding --prefix
20170405:13:41:58:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-gp_restore commandline: gp_restore -i -h db-192-168-101-115.sky-mobi.com -p 1922 -U gpadmin --gp-d=/home/gpadmin/backup/db_dumps/20170401 --gp-i --gp-k=20170401151503 --gp-l=p --gp-r=/home/gpadmin/backup --status=/home/gpadmin/backup --prefix=hank_ --gp-c -d "hank": 
20170405:13:42:19:024505 gpdbrestore:db-192-168-101-115:gpadmin-[WARNING]:-gpdbrestore finished but ERRORS were found, please check the restore report file for details
20170405:13:42:19:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Updating AO/CO statistics on master
20170405:13:42:19:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-No AO/CO tables restored, skipping statistics update...
20170405:13:42:19:024505 gpdbrestore:db-192-168-101-115:gpadmin-[INFO]:-Commencing restore of statistics
gpadmin@db-192-168-101-115-> psql
psql (8.2.15)
Type "help" for help.

postgres=# \c hank hank
You are now connected to database "hank" as user "hank".
hank=> \dt
                    List of relations
 Schema |        Name        | Type  |  Owner  | Storage 
--------+--------------------+-------+---------+---------
 hank   | tb1                | table | hank    | heap
 hank   | test               | table | hank    | heap
 hank   | test1              | table | hank    | heap
 public | gpcrondump_history | table | gpadmin | heap
(4 rows)

hank=> 
hank=> 
hank=> 
hank=> select count(*) from tb1;
  count   
----------
 10000000
(1 row)
0 0
原创粉丝点击