目录
并行备份还原
并行备份
并行恢复
返回值
要执行数据库的完整备份及数据库系统元数据,请使用以下命令:
$ gpbackup --dbname
例如:
$ gpbackup --dbname demo
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Starting backup of database demo
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Backup Timestamp = 20180105112754
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Backup Database = demo
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Backup Type = Unfiltered Compressed Full Backup
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Gathering list of tables for backup
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Acquiring ACCESS SHARE locks on tables
Locks acquired: 6 / 6 [================================================================] 100.00% 0s
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Gathering additional table metadata
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Writing global database metadata
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Global database metadata backup complete
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Writing pre-data metadata
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Pre-data metadata backup complete
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Writing post-data metadata
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Post-data metadata backup complete
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Writing data to file
Tables backed up: 3 / 3 [==============================================================] 100.00% 0s
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Data backup complete
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Found neither /usr/local/mpp-db/./bin/gp_email_contacts.yaml nor /home/gpadmin/gp_email_contacts.yaml
20180105:11:27:54 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Email containing gpbackup report /gpmaster/seg-1/backups/20180105/20180105112754/gpbackup_20180105112754_report will not be sent
20180105:11:27:55 gpbackup:mppadmin:centos6.localdomain:002182-[INFO]:-Backup completed
上面的命令在数据库master主机的默认目录中创建一个包含全局和数据库特定元数据的文件, $MASTER_DATA_DIRECTORY/backups/
$ ls /gpmaster/gpsne-1/backups/20180105/20180105112754
gpbackup_20180105112754_config.yaml gpbackup_20180105112754_report
gpbackup_20180105112754_metadata.sql gpbackup_20180105112754_toc.yaml
默认情况下,每个节点用一个独立的压缩CSV文件在
$ ls /gpdata1/gpsne0/backups/20180105/20180105112754/
gpbackup_0_20180105112754_17166.gz gpbackup_0_20180105112754_26303.gz
gpbackup_0_20180105112754_21816.gz
要将所有备份文件合并到一个目录中,请包含--backup-dir选项。 请注意,必须使用此选项指定绝对路径:
$ gpbackup --dbname demo --backup-dir /home/mppadmin/backups
20171103:15:31:56 gpbackup:mppadmin:0ee2f5fb02c9:017586-[INFO]:-Starting backup of database demo
...
20171103:15:31:58 gpbackup:mppadmin:0ee2f5fb02c9:017586-[INFO]:-Backup completed successfully
$ find /home/mppadmin/backups/ -type f
/home/mppadmin/backups/gpseg0/backups/20171103/20171103153156/gpbackup_0_20171103153156_16543.gz
/home/mppadmin/backups/gpseg0/backups/20171103/20171103153156/gpbackup_0_20171103153156_16524.gz
/home/mppadmin/backups/gpseg1/backups/20171103/20171103153156/gpbackup_1_20171103153156_16543.gz
/home/mppadmin/backups/gpseg1/backups/20171103/20171103153156/gpbackup_1_20171103153156_16524.gz
/home/mppadmin/backups/gpseg-1/backups/20171103/20171103153156/gpbackup_20171103153156_config.yaml
/home/mppadmin/backups/gpseg-1/backups/20171103/20171103153156/gpbackup_20171103153156_predata.sql
/home/mppadmin/backups/gpseg-1/backups/20171103/20171103153156/gpbackup_20171103153156_global.sql
/home/mppadmin/backups/gpseg-1/backups/20171103/20171103153156/gpbackup_20171103153156_postdata.sql
/home/mppadmin/backups/gpseg-1/backups/20171103/20171103153156/gpbackup_20171103153156_report
/home/mppadmin/backups/gpseg-1/backups/20171103/20171103153156/gpbackup_201711031531
执行备份操作时,可以在多个文件的额外开销可能过高的情况下使用--single-data-file。
使用gprestore从备份集合恢复,必须使用--timestamp选项指定准确的时间戳值 (YYYYMMDDHHMMSS)。 包括--create-db选项,如果数据库未在集群中创建。 例如:
$ dropdb demo
$ gprestore --timestamp 20171103152558 --create-db
20171103:15:45:30 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Restore Key = 20171103152558
20171103:15:45:31 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Creating database
20171103:15:45:44 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Database creation complete
20171103:15:45:44 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Restoring pre-data metadata from /gpmaster/gpsne-1/backups/20171103/20171103152558/gpbackup_20171103152558_predata.sql
20171103:15:45:45 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Pre-data metadata restore complete
20171103:15:45:45 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Restoring data
20171103:15:45:45 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Data restore complete
20171103:15:45:45 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Restoring post-data metadata from /gpmaster/gpsne-1/backups/20171103/20171103152558/gpbackup_20171103152558_postdata.sql
20171103:15:45:45 gprestore:mppadmin:0ee2f5fb02c9:017714-[INFO]:-Post-data metadata restor
如果指定自定义的--backup-dir来合并备份文件,使用gprestore时指定相同的--backup-dir选项来定位备份文件:
$ dropdb demo
$ gprestore --backup-dir /home/mppadmin/backups/ --timestamp 20171103153156 --create-db
20171103:15:51:02 gprestore:mppadmin:0ee2f5fb02c9:017819-[INFO]:-Restore Key = 20171103153156
...
20171103:15:51:17 gprestore:mppadmin:0ee2f5fb02c9:017819-[INFO]:-Post-data metadata restore c
默认情况下,gprestore使用一个连接去恢复表数据和元数据。 如果备份集非常大,可以使用--jobs选项来提高并发连接数从而提升恢复性能。 例如:
$ gprestore --backup-dir /home/mppadmin/backups/ --timestamp 20171103153156 --create-db
执行备份操作时,gpbackup会将备份信息附加到数据库master数据目录中的gpbackup历史文件gpbackup_history.yaml中。 该文件包含备份时间戳,有关备份选项的信息以及增量备份的备份集信息。 gpbackup不备份此文件。使用--incremental选项运行gpbackup时, gpbackup使用文件中的信息查找增量备份的匹配备份, 并且不指定--from-timesamp选项以指示要用作最新备份的备份在增量备份集中。
在gpbackup或gprestore完成时会返回下面的一个返回值。