分类: Mysql/postgreSQL
2016-03-15 11:43:56
存放CREATE DATABASE语句,用来重建数据库。
gp_dump_status_1__ # 日志文件,存放备份日志
gp_dump_1__ # schema中对象的定义(DDL)文件
gp_dump_1___post_data # 含有和重建表相关的对象。主要是一些参数。官方解释:contains commands to rebuild objects associated with the tables.
gp_dump_.rpt # 备份报告,包含Timestamp Key,gp_dump Command Line,Backup Type(全备或者增量),备份是否成功等。
# ps -ef|grep gp_dump_agent
gpadmin 9200 9183 0 14:28 ? 00:00:00 sh -c /opt/greenplum/greenplum-db/./bin/gp_dump_agent --gp-k 20160304142801_0_2_ --gp-d /gpbackup/ -p 40000 -U gpadmin -a testDB 2> /gpbackup/gp_dump_status_0_2_20160304142801 > /gpbackup/gp_dump_0_2_20160304142801
gpadmin 9201 9200 3 14:28 ? 00:00:01 /opt/greenplum/greenplum-db/./bin/gp_dump_agent --gp-k 20160304142801_0_2_ --gp-d /gpbackup/ -p 40000 -U gpadmin -a testDB
root 9212 7002 0 14:28 pts/1 00:00:00 grep gp_dump_agent
gp_dump_0__ # 数据备份文件,例如 gp_dump_0_2_20160304111611
gp_dump_status_0__ # 日志文件,例如gp_dump_status_0_2_20160304111611
$ gp_dump --help
gp_dump dumps a database as a text file or to other formats.
Usage:
gp_dump [OPTION]... [DBNAME]
General options:
-i, --ignore-version proceed even when server version mismatches
gp_dump version
-v, --verbose verbose mode. adds verbose information to the
per segment status files
--help show this help, then exit
--version output version information, then exit
Options controlling the output content:
-a, --data-only dump only the data, not the schema
-c, --clean clean (drop) schema prior to create
-d, --inserts dump data as INSERT, rather than COPY, commands
-D, --column-inserts dump data as INSERT commands with column names
-E, --encoding=ENCODING dump the data in encoding ENCODING
-n, --schema=SCHEMA dump the named schema only
-N, --exclude-schema=SCHEMA do NOT dump the named schema(s)
-o, --oids include OIDs in dump
-O, --no-owner do not output commands to set object ownership
in plain text format
-s, --schema-only dump only the schema, no data
-S, --superuser=NAME specify the superuser user name to use in
plain text format
-t, --table=TABLE dump only matching table(s) (or views or sequences)
-T, --exclude-table=TABLE do NOT dump matching table(s) (or views or sequences)
-x, --no-privileges do not dump privileges (grant/revoke)
--disable-triggers disable triggers during data-only restore
--incremental dump only modified patitions
--use-set-session-authorization
use SESSION AUTHORIZATION commands instead of
ALTER OWNER commands to set ownership
Connection options:
-h, --host=HOSTNAME database server host or socket directory
-p, --port=PORT database server port number
-U, --username=NAME connect as specified database user
-W, --password force password prompt (should happen automatically)
Greenplum Database specific options:
--gp-c use gzip for in-line compression
--gp-d=BACKUPFILEDIR directory where backup files are placed
--gp-k=TIMESTAMP timestamp key to be used for the dump files
--gp-r=REPORTFILEDIR directory where report file is placed
--gp-s=BACKUPSET backup set indicator - (p)rimaries only (default)
or (i)ndividual segdb (must be followed with a list of dbids
of primary segments to dump. For example: --gp-s=i[10,12,14]
--rsyncable pass --rsyncable option to gzip
If no database name is supplied, then the PGDATABASE environment
variable value is used.
$ gp_restore --help
gp_restore restores a Greenplum Database database from an archive created by gp_dump.
Usage:
gp_restore [OPTIONS]
General options:
-d, --dbname=NAME output database name
-i, --ignore-version proceed even when server version mismatches
-v, --verbose verbose mode. adds verbose information to the
per segment status files
--help show this help, then exit
--version output version information, then exit
Options controlling the output content:
-a, --data-only restore only the data, no schema
-s, --schema-only restore only the schema, no data
-P, --post-data-schema-only restore only the postdataSchema
Connection options:
-h, --host=HOSTNAME database server host or socket directory
-p, --port=PORT database server port number
-U, --username=NAME connect as specified database user
-W, --password force password prompt (should happen automatically)
Greenplum Database specific options:
--gp-c use gunzip for in-line de-compression
--gp-d=BACKUPFILEDIR directory where backup files are located
--gp-i ignore error
--gp-k=KEY date time backup key from gp_backup run
--gp-r=REPORTFILEDIR directory where report file is placed
--status=STATUSFILEDIR directory where status file is placed
--gp-l=FILELOCATIONS backup files are on (p)rimaries only (default)
or (i)ndividual segdb (must be followed with a list of dbid's
where backups are located. For example: --gp-l=i[10,12,15]
--gp-f=FILE FILE, present on all machines, with tables to include in restore
--prefix=PREFIX PREFIX of the dump files to be restored
$ gp_dump szlsd_db --table=member --gp-d=/gpbackup/ --gp-r=/gpbackup/
20160304:11:16:11|gp_dump-[INFO]:-Read params: -t member
20160304:11:16:11|gp_dump-[INFO]:-Command line options analyzed.
20160304:11:16:11|gp_dump-[INFO]:-Connecting to master database on host localhost port 5432 database szlsd_db.
20160304:11:16:11|gp_dump-[INFO]:-Reading Greenplum Database configuration info from master database.
20160304:11:16:11|gp_dump-[INFO]:-Preparing to dump the following segments:
20160304:11:16:11|gp_dump-[INFO]:-Segment 2 (dbid 4)
20160304:11:16:11|gp_dump-[INFO]:-Segment 1 (dbid 3)
20160304:11:16:11|gp_dump-[INFO]:-Segment 0 (dbid 2)
20160304:11:16:11|gp_dump-[INFO]:-Master (dbid 1)
20160304:11:16:11|gp_dump-[INFO]:-Converting tablenames to oids
20160304:11:16:11|gp_dump-[INFO]:-Processing tables in batches of 1000
20160304:11:16:11|gp_dump-[INFO]:-Finished processing batch 1 of tables
20160304:11:16:11|gp_dump-[INFO]:-Starting a transaction on master database szlsd_db.
20160304:11:16:11|gp_dump-[INFO]:-Getting a lock on pg_class in database szlsd_db.
20160304:11:16:11|GetTimestampKey-[INFO]:-Timestamp key is generated as it is not provided by the user.
20160304:11:16:11|gp_dump-[INFO]:-About to spin off 4 threads with timestamp key 20160304111611
20160304:11:16:11|gp_dump-[INFO]:-Creating thread to backup dbid 4: host gp-s3 port 40000 database szlsd_db
20160304:11:16:11|gp_dump-[INFO]:-Creating thread to backup dbid 3: host gp-s2 port 40000 database szlsd_db
20160304:11:16:11|gp_dump-[INFO]:-Creating thread to backup dbid 2: host gp-s1 port 40000 database szlsd_db
20160304:11:16:11|gp_dump-[INFO]:-Creating thread to backup dbid 1: host gp-master port 5432 database szlsd_db
20160304:11:16:11|gp_dump-[INFO]:-Waiting for remote gp_dump_agent processes to start transactions in serializable isolation level
20160304:11:16:11|gp_dump-[INFO]:-Listening for messages from server on dbid 2 connection
20160304:11:16:11|gp_dump-[INFO]:-Listening for messages from server on dbid 4 connection
20160304:11:16:11|gp_dump-[INFO]:-Successfully launched Greenplum Database backup on dbid 2 server
20160304:11:16:11|gp_dump-[INFO]:-Successfully launched Greenplum Database backup on dbid 4 server
20160304:11:16:11|gp_dump-[INFO]:-Listening for messages from server on dbid 3 connection
20160304:11:16:11|gp_dump-[INFO]:-Successfully launched Greenplum Database backup on dbid 3 server
20160304:11:16:11|gp_dump-[INFO]:-Listening for messages from server on dbid 1 connection
20160304:11:16:13|gp_dump-[INFO]:-Successfully launched Greenplum Database backup on dbid 1 server
20160304:11:16:13|gp_dump-[INFO]:-backup succeeded for dbid 1 on host gp-master
20160304:11:16:14|gp_dump-[INFO]:-backup succeeded for dbid 4 on host gp-s3
20160304:11:16:14|gp_dump-[INFO]:-All remote gp_dump_agent processes have began transactions in serializable isolation level
20160304:11:16:14|gp_dump-[INFO]:-Waiting for remote gp_dump_agent processes to obtain local locks on dumpable objects
20160304:11:16:14|gp_dump-[INFO]:-All remote gp_dump_agent processes have obtains the necessary locks
20160304:11:16:14|gp_dump-[INFO]:-Committing transaction on the master database, thereby releasing locks.
20160304:11:16:14|gp_dump-[INFO]:-Waiting for all remote gp_dump_agent programs to finish.
20160304:11:16:14|gp_dump-[INFO]:-backup succeeded for dbid 2 on host gp-s1
20160304:11:16:16|gp_dump-[INFO]:-backup succeeded for dbid 3 on host gp-s2
20160304:11:16:16|gp_dump-[INFO]:-All remote gp_dump_agent programs are finished.
20160304:11:16:16|gp_dump-[INFO]:-Report results also written to /gpbackup/gp_dump_20160304111611.rpt.
Greenplum Database Backup Report
Timestamp Key: 20160304111611
gp_dump Command Line: szlsd_db --table=member --gp-d=/gpbackup/ --gp-r=/gpbackup/
Pass through Command Line Options: -t member -t member_1_prt_other -t member_1_prt_boys -t member_1_prt_girls
Compression Program: None
Backup Type: Full
Individual Results
segment 2 (dbid 4) Host gp-s3 Port 40000 Database szlsd_db BackupFile /gpbackup/gp_dump_0_4_20160304111611: Succeeded
segment 1 (dbid 3) Host gp-s2 Port 40000 Database szlsd_db BackupFile /gpbackup/gp_dump_0_3_20160304111611: Succeeded
segment 0 (dbid 2) Host gp-s1 Port 40000 Database szlsd_db BackupFile /gpbackup/gp_dump_0_2_20160304111611: Succeeded
Master (dbid 1) Host gp-master Port 5432 Database szlsd_db BackupFile /gpbackup/gp_dump_1_1_20160304111611: Succeeded
Master (dbid 1) Host gp-master Port 5432 Database szlsd_db BackupFile /gpbackup/gp_dump_1_1_20160304111611_post_data: Succeeded
gp_dump utility finished successfully.
$ gp_restore --gp-d=/gpbackup/ --gp-r=/gpbackup/ --gp-k=20160304111611
20160304:15:28:59|gp_restore-[INFO]:-Analyzed command line options.
20160304:15:28:59|gp_restore-[INFO]:-Connecting to master segment on host localhost port 5432 database testDB.
20160304:15:28:59|gp_restore-[INFO]:-Reading Greenplum Database configuration info from master segment database.
20160304:15:28:59|gp_restore-[INFO]:-Preparing to restore the following segments:
20160304:15:28:59|gp_restore-[INFO]:-Segment 2 (dbid 4)
20160304:15:28:59|gp_restore-[INFO]:-Segment 1 (dbid 3)
20160304:15:28:59|gp_restore-[INFO]:-Segment 0 (dbid 2)
20160304:15:28:59|gp_restore-[INFO]:-Master (dbid 1)
20160304:15:28:59|gp_restore-[INFO]:-Starting to restore the master database.
20160304:15:28:59|gp_restore-[INFO]:-Creating thread to restore master database: host gp-master port 5432 database testDB
20160304:15:28:59|gp_restore-[INFO]:-Listening for messages from dbid 1 server (source) for dbid 1 restore
20160304:15:28:59|gp_restore-[INFO]:-Successfully launched Greenplum Database restore on dbid 1 to restore dbid 1
20160304:15:29:02|gp_restore-[INFO]:-restore started for source dbid 1, target dbid 1 on host gp-master
20160304:15:29:02|gp_restore-[INFO]:-restore succeeded for source dbid 1, target dbid 1 on host gp-master
20160304:15:29:02|gp_restore-[INFO]:-Successfully restored master database: host gp-master port 5432 database testDB
20160304:15:29:02|gp_restore-[INFO]:-Creating thread to restore dbid 4 (gp-s3:40000) from backup file on dbid 4 (gp-s3:40000)
20160304:15:29:02|gp_restore-[INFO]:-Creating thread to restore dbid 3 (gp-s2:40000) from backup file on dbid 3 (gp-s2:40000)
20160304:15:29:02|gp_restore-[INFO]:-Creating thread to restore dbid 2 (gp-s1:40000) from backup file on dbid 2 (gp-s1:40000)
20160304:15:29:02|gp_restore-[INFO]:-Waiting for all remote gp_restore_agent programs to finish.
20160304:15:29:02|gp_restore-[INFO]:-Listening for messages from dbid 2 server (source) for dbid 2 restore
20160304:15:29:02|gp_restore-[INFO]:-Listening for messages from dbid 3 server (source) for dbid 3 restore
20160304:15:29:02|gp_restore-[INFO]:-Successfully launched Greenplum Database restore on dbid 3 to restore dbid 3
20160304:15:29:02|gp_restore-[INFO]:-Listening for messages from dbid 4 server (source) for dbid 4 restore
20160304:15:29:02|gp_restore-[INFO]:-Successfully launched Greenplum Database restore on dbid 2 to restore dbid 2
20160304:15:29:02|gp_restore-[INFO]:-Successfully launched Greenplum Database restore on dbid 4 to restore dbid 4
20160304:15:29:06|gp_restore-[INFO]:-restore started for source dbid 2, target dbid 2 on host gp-s1
20160304:15:29:06|gp_restore-[INFO]:-restore started for source dbid 3, target dbid 3 on host gp-s2
20160304:15:29:06|gp_restore-[INFO]:-restore started for source dbid 4, target dbid 4 on host gp-s3
20160304:15:29:10|gp_restore-[INFO]:-restore succeeded for source dbid 2, target dbid 2 on host gp-s1
20160304:15:29:12|gp_restore-[INFO]:-restore succeeded for source dbid 4, target dbid 4 on host gp-s3
20160304:15:29:18|gp_restore-[INFO]:-restore succeeded for source dbid 3, target dbid 3 on host gp-s2
20160304:15:29:18|gp_restore-[INFO]:-All remote gp_restore_agent programs are finished.
20160304:15:29:18|gp_restore-[INFO]:-updating Append Only table statistics
20160304:15:29:18|gp_restore-[INFO]:-Starting to restore the master database.
20160304:15:29:18|gp_restore-[INFO]:-Creating thread to restore master database: host gp-master port 5432 database testDB
20160304:15:29:18|gp_restore-[INFO]:-Listening for messages from dbid 1 server (source) for dbid 1 restore
20160304:15:29:18|gp_restore-[INFO]:-Successfully launched Greenplum Database restore on dbid 1 to restore dbid 1
20160304:15:29:20|gp_restore-[INFO]:-restore started for source dbid 1, target dbid 1 on host gp-master
20160304:15:29:20|gp_restore-[INFO]:-restore succeeded for source dbid 1, target dbid 1 on host gp-master
20160304:15:29:20|gp_restore-[INFO]:-Successfully restored master database: host gp-master port 5432 database testDB
20160304:15:29:20|gp_restore-[INFO]:-Report results also written to /gpbackup/gp_restore_20160304152431.rpt.
Greenplum Database Restore Report
Timestamp Key: 20160304152431
gp_restore Command Line: --gp-d=/gpbackup/ --gp-r=/gpbackup/ --gp-k=20160304152431
Pass through Command Line Options: --post-data-schema-only
Compression Program: None
Individual Results
Restore of testDB on dbid 1 (gp-master:5432) from /gpbackup/gp_dump_1_1_20160304152431_post_data: Succeeded
Restore of testDB on dbid 4 (gp-s3:40000) from /gpbackup/gp_dump_0_4_20160304152431: Succeeded
Restore of testDB on dbid 3 (gp-s2:40000) from /gpbackup/gp_dump_0_3_20160304152431: Succeeded
Restore of testDB on dbid 2 (gp-s1:40000) from /gpbackup/gp_dump_0_2_20160304152431: Succeeded
gp_restore utility finished successfully.
$ gp_dump testDB --gp-d=/gpbackup/ --gp-r=/gpbackup/
test=# create database "testDB" with owner=gpadmin;
$ gp_restore --gp-d=/gpbackup/ --gp-r=/gpbackup/ --gp-k=20160304153252
$ gp_dump szlsd_db -n public --gp-d=/gpbackup/ --gp-r=/gpbackup/
testDB=# drop schema public cascade;
testDB=# create schema public ;
CREATE SCHEMA
$ gp_restore --gp-d=/gpbackup/ --gp-r=/gpbackup/ --status=/gpbackup/ --gp-k=20160304163404
$ gp_dump szlsd_db -n public --gp-d=/gpbackup/ --gp-r=/gpbackup/ --gp-k=xxxxxxxxxxx
$ gp_dump szlsd_db -n public --gp-d=/gpbackup/ --gp-r=/gpbackup/ --incremental