Greenplum的全量备份之gpcrondump
********************** Return Codes ********************** The following is a list of the codes that gpcrondump returns. 0 - Dump completed with no problems 1 - Dump completed, but one or more warnings were generated 2 - Dump failed with a fatal error -a (do not prompt) Do not prompt the user for confirmation. -d <master_data_directory> The master host data directory. If not specified, the value set for $MASTER_DATA_DIRECTORY will be used. --dump-stats Dump optimizer statistics from pg_statistic. Statistics are dumped in the master data directory to db_dumps/YYYYMMDD/gp_statistics_1_1_<timestamp>. -g (copy config files) Secure a copy of the master and segment configuration files postgresql.conf, pg_ident.conf, and pg_hba.conf. These configuration files are dumped in the master or segment data directory to db_dumps/YYYYMMDD/config_files_<timestamp>.tar. If --ddboost is specified, the backup is located on the default storage unit in the directory specified by --ddboost-backupdir when the Data Domain Boost credentials were set. -G (dump global objects) Use pg_dumpall to dump global objects such as roles and tablespaces. Global objects are dumped in the master data directory to db_dumps/YYYYMMDD/gp_global_1_1_<timestamp>. -h (record dump details) Record details of database dump in database table public.gpcrondump_history in database supplied via -x option. Utility will create table if it does not currently exist. --incremental (backup changes to append-optimized tables) Adds an incremental backup to a backup set. When performing an incremental backup, the complete backup set created prior to the incremental backup must be available. The complete backup set includes the following backup files: * The last full backup before the current incremental backup * All incremental backups created between the time of the full backup the current incremental backup An incremental backup is similar to a full back up except for append-optimized tables, including column-oriented tables. An append-optimized table is backed up only if at least one of the following operations was performed on the table after the last backup. ALTER TABLE INSERT UPDATE DELETE TRUNCATE DROP and then re-create the table For partitioned append-optimized tables, only the changed table partitions are backed up. The -u option must be used consistently within a backup set that includes a full and incremental backups. If you use the -u option with a full backup, you must use the -u option when you create incremental backups that are part of the backup set that includes the full backup. You can create an incremental backup for a full backup of set of database tables. When you create the full backup, specify the --prefix option to identify the backup. To include a set of tables in the full backup, use either the -t option or --table-file option. To exclude a set of tables, use either the -T option or the --exclude-table-file option. See the description of the option for more information on its use. To create an incremental backup based on the full backup of the set of tables, specify the option --incremental and the --prefix option with the string specified when creating the full backup. The incremental backup is limited to only the tables in the full backup. WARNING: gpcrondump does not check for available disk space prior to performing an incremental backup. IMPORTANT: An incremental back up set, a full backup and associated incremental backups, must be on a single device. For example, a the backups in a backup set must all be on a file system or must all be on a Data Domain system. --prefix <prefix_string> [--list-filter-tables ] Prepends <prefix_string> followed by an underscore character (_) to the names of all the backup files created during a backup. -r (rollback on failure) Rollback the dump files (delete a partial dump) if a failure is detected. The default is to not rollback. -u <backup_directory> Specifies the absolute path where the backup files will be placed on each host. If the path does not exist, it will be created, if possible. If not specified, defaults to the data directory of each instance to be backed up. Using this option may be desirable if each segment host has multiple segment instances as it will create the dump files in a centralized location rather than the segment data directories. Note: This option is not supported if --ddboost is specified. --use-set-session-authorization Use SET SESSION AUTHORIZATION commands instead of ALTER OWNER commands to set object ownership. -x <database_name> Required. The name of the Greenplum database to dump. Specify multiple times for multiple databases.
操作新体验 备份数据库 lottu (其中 -x lottu 为指定数据库)
[gpadmin@mdw ~]$ gpcrondump -a -C --dump-stats -g -G -h -r --use-set-session-authorization -x lottu -u /home/gpadmin/backup --prefix lottu -l /home/gpadmin/backup 20160713:16:02:36:044710 gpcrondump:mdw:gpadmin-[INFO]:-Starting gpcrondump with args: -a -C --dump-stats -g -G -h -r --use-set-session-authorization -x lottu -u /home/gpadmin/backup --prefix lottu -l /home/gpadmin/backup 20160713:16:02:52:044710 gpcrondump:mdw:gpadmin-[INFO]:-Directory /home/gpadmin/backup/db_dumps/20160713 not found, will try to create 20160713:16:02:52:044710 gpcrondump:mdw:gpadmin-[INFO]:-Created /home/gpadmin/backup/db_dumps/20160713 20160713:16:02:52:044710 gpcrondump:mdw:gpadmin-[INFO]:-Checked /home/gpadmin/backup on master 20160713:16:03:14:044710 gpcrondump:mdw:gpadmin-[INFO]:-Configuring for single database dump 20160713:16:03:14:044710 gpcrondump:mdw:gpadmin-[INFO]:-Validating disk space 20160713:16:03:19:044710 gpcrondump:mdw:gpadmin-[INFO]:-Creating filter file: /home/gpadmin/backup/db_dumps/20160713/lottu_gp_dump_20160713160238_filter 20160713:16:03:19:044710 gpcrondump:mdw:gpadmin-[INFO]:-Adding compression parameter 20160713:16:03:19:044710 gpcrondump:mdw:gpadmin-[INFO]:-Adding --prefix 20160713:16:03:19:044710 gpcrondump:mdw:gpadmin-[INFO]:-Adding --no-expand-children 20160713:16:03:19:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump process command line gp_dump -p 1921 -U gpadmin --gp-d=/home/gpadmin/backup/db_dumps/20160713 --gp-r=/home/gpadmin/backup/db_dumps/20160713 --gp-s=p --gp-k=20160713160238 --no-lock -c --gp-c --prefix=lottu_ --no-expand-children "lottu" --use-set-session-authorization 20160713:16:03:19:044710 gpcrondump:mdw:gpadmin-[INFO]:-Starting Dump process 20160713:16:03:26:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump process returned exit code 0 20160713:16:03:26:044710 gpcrondump:mdw:gpadmin-[INFO]:-Timestamp key = 20160713160238 20160713:16:03:26:044710 gpcrondump:mdw:gpadmin-[INFO]:-Checked master status file and master dump file. 20160713:16:03:26:044710 gpcrondump:mdw:gpadmin-[INFO]:-Releasing pg_class lock 20160713:16:03:29:044710 gpcrondump:mdw:gpadmin-[INFO]:-Commencing pg_statistic dump 20160713:16:03:31:044710 gpcrondump:mdw:gpadmin-[INFO]:-Created public.gpcrondump_history in lottu database 20160713:16:03:33:044710 gpcrondump:mdw:gpadmin-[INFO]:-Inserted dump record into public.gpcrondump_history in lottu database 20160713:16:03:33:044710 gpcrondump:mdw:gpadmin-[INFO]:-Commencing pg_catalog dump 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump status report 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:---------------------------------------------------- 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Target database = lottu 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump subdirectory = 20160713 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump type = Full database 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Clear old dump directories = Off 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump start time = 16:02:38 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump end time = 16:03:26 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Status = COMPLETED 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump key = 20160713160238 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dump file compression = On 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Vacuum mode type = Off 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Exit code zero, no warnings generated 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:---------------------------------------------------- 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dumping master config files 20160713:16:03:34:044710 gpcrondump:mdw:gpadmin-[INFO]:-Dumping segment config files 20160713:16:03:36:044710 gpcrondump:mdw:gpadmin-[WARNING]:-Found neither /usr/local/greenplum-db438/bin/mail_contacts nor /home/gpadmin/mail_contacts 20160713:16:03:36:044710 gpcrondump:mdw:gpadmin-[WARNING]:-Unable to send dump email notification 20160713:16:03:36:044710 gpcrondump:mdw:gpadmin-[INFO]:-To enable email notification, create /usr/local/greenplum- db438/bin/mail_contacts or /home/gpadmin/mail_contacts containing required email addresses
lottu_zhu@staff.easou.com yee_yi@staff.easou.com
其中备份数据,自动生成子目录,输出到/home/gpadmin/backup/db_dumps/yyyymmdd目录下
[gpadmin@mdw 20160713]$ ll total 60 -rw-------. 1 gpadmin gpadmin 136 Jul 13 16:03 lottu_gp_cdatabase_1_1_20160713160238 -rw-------. 1 gpadmin gpadmin 758 Jul 13 16:03 lottu_gp_dump_1_1_20160713160238.gz -rw-------. 1 gpadmin gpadmin 374 Jul 13 16:03 lottu_gp_dump_1_1_20160713160238_post_data.gz -rw-rw-r--. 1 gpadmin gpadmin 0 Jul 13 16:03 lottu_gp_dump_20160713160238_ao_state_file -rw-rw-r--. 1 gpadmin gpadmin 0 Jul 13 16:03 lottu_gp_dump_20160713160238_co_state_file -rw-rw-r--. 1 gpadmin gpadmin 0 Jul 13 16:03 lottu_gp_dump_20160713160238_last_operation -rw-rw-r--. 1 gpadmin gpadmin 1129 Jul 13 16:03 lottu_gp_dump_20160713160238.rpt -rw-------. 1 gpadmin gpadmin 2403 Jul 13 16:03 lottu_gp_dump_status_1_1_20160713160238 -rw-rw-r--. 1 gpadmin gpadmin 1041 Jul 13 16:03 lottu_gp_global_1_1_20160713160238 -rw-rw-r--. 1 gpadmin gpadmin 30720 Jul 13 16:03 lottu_gp_master_config_files_20160713160238.tar -rw-rw-r--. 1 gpadmin gpadmin 1500 Jul 13 16:03 lottu_gp_statistics_1_1_20160713160238 [gpadmin@mdw 20160713]$ pwd /home/gpadmin/backup/db_dumps/20160713
每个数据库中都会记录对应数据库的备份历史信息。涉及系统表gpcrondump_history
lottu=# \d gpcrondump* Table "public.gpcrondump_history" Column | Type | Modifiers --------------------+-----------------------------+----------- rec_date | timestamp without time zone | start_time | character(8) | end_time | character(8) | options | text | dump_key | character varying(20) | dump_exit_status | smallint | script_exit_status | smallint | exit_text | character varying(10) | Distributed by: (rec_date) lottu=# \x Expanded display is on. lottu=# select * from gpcrondump_history; -[ RECORD 1 ]------+--------------------------------------------------------------------------------------------------------------------------------------- rec_date | 2016-07-13 16:03:32.079202 start_time | 16:02:38 end_time | 16:03:26 options | -a -C --dump-stats -g -G -h -r --use-set-session-authorization -x lottu -u /home/gpadmin/backup --prefix lottu -l /home/gpadmin/backup dump_key | 20160713160238 dump_exit_status | 0 script_exit_status | 0 exit_text | COMPLETED
最后奉上备份脚本:再加入定时任务中;每天可以执行备份
#!/bin/sh backupdir="/home/gpadmin/backup" logdir=$backupdir dbid="lottu" for dbname in `psql -A -q -t -c "select datname from pg_database where datname <>'template0'"` do now=`date +%Y%m%d%H%M%S` gpcrondump -a -C --dump-stats -g -G -h -r --use-set-session-authorization -x $dbname -u $backupdir --prefix $dbid -l $logdir -d $masterdir -K $now done
--参考文献:德哥 https://yq.aliyun.com/articles/30330?spm=5176.8067842.tagmain.19.etfAn9
Greenplum的全量备份之gpcrondump的更多相关文章
- mysql备份脚本,每天执行一次全量备份,三次增量备份
线上一个小业务的mysql备份 全量备份 #!/bin/bash #crete by hexm at -- #scripte name : full_backup.sh #descriptioni : ...
- SVN全量备份+增量备份脚本
一.全量备份 环境:一台主SVN,一台备SVN(主要提供备份功能),后续可通过钩子脚本进行实时备份,后续发给大家. 工作原理:通过svn的hotcopy命令过行热备份,并进行一系列的检查,备份后通过r ...
- xtrabackup全量备份和增(差)量备份
xtrabackup全量备份和增(差)量备份 1.xtrabackup全量备份和恢复 1)备份: innobackupex --default-file=/PATH/TO/DEFAULT --host ...
- Centos 6.9 安装xtrabackup-2.4.8 通用包,yum安装,全量备份,增量备份
xtrabackup-2.4.8的安装及使用 Xtrabackup是由percona提供的mysql数据库备份工具,据官方介绍,这也是世界上惟一一款开源的能够对innodb和xtradb数据库进行热备 ...
- MySQL innobackupex全量备份恢复
转自 http://blog.itpub.net/27099995/viewspace-1295099/ 先简单介绍一下这个工具:innobackupexinnobackupex比xtarbackup ...
- mysql 全量备份与增量备份
全量备份[root@master adm]# cat DBfullBak.sh #!/bin/bash #use mysqldump to fully backup mysql data BakDir ...
- Linux 网站文件和数据库全量备份 一键脚本(支持FTP,Google Drive)
原文连接: https://teddysun.com/469.html 此文为转载,建议查看秋水大神的原文,排版更容易查看,另外,建议查看脚本源码,方便了解脚本运行过程, 脚本已测试,大神的脚本一如既 ...
- 15、xtrabackup 全量备份
xtrabackup 全量备份与恢复 安装 yum install https://www.percona.com/downloads/XtraBackup/Percona-XtraBackup-2. ...
- Mysql 增量备份和全量备份
全量备份: # vim /root/DBFullyBak.sh //添加以下内容 #!/bin/bash # Program # use mysqldump to Fully backup mysql ...
随机推荐
- Ajax.ActionLink()方法的使用
第一句话都会这么去写:程序猿就是苦逼,除了开发还要会写博文!哎,今天就和大家一起讨论下Ajax的辅助方法ActionLink的使用,如果有讲的不好的地方或错的地方,请大家务必扔板砖,要投准哦,砸死我算 ...
- 使用 jQuery Deferred 和 Promise 创建响应式应用程序
这篇文章,我们一起探索一下 JavaScript 中的 Deferred 和 Promise 的概念,它们是 JavaScript 工具包(如Dojo和MochiKit)中非常重要的一个功能,最近也首 ...
- PAT 解题报告 1049. Counting Ones (30)
1049. Counting Ones (30) The task is simple: given any positive integer N, you are supposed to count ...
- Inventory Pro 装备拾取的实现
以后都按照插件使用,提出问题,回答问题的方式来进行总结和学习 效果图 1.运行相关的例子,场景中出现4个矩形,这4个矩形是用来模拟物品掉落的包裹,移动Player靠近物品 2.使用鼠标点击物品正方体, ...
- java mock
一篇文章: 5分钟了解Mockito 一.什么是mock测试,什么是mock对象? 先来看看下面这个示例: 从上图可以看出如果我们要对A进行测试,那么就要先把整个依赖树构建出来,也就是BCDE的实例. ...
- Lintcode: Minimum Adjustment Cost
Given an integer array, adjust each integers so that the difference of every adjcent integers are no ...
- acm算法模板(5)
STL 中 sort 函数用法简介 做 ACM 题的时候,排序是一种经常要用到的操作.如果每次都自己写个冒泡之类的 O(n^2) 排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错. ST ...
- Java基础(32):String与StringBuilder、StringBuffer的区别(String类)
在Java中,除了可以使用 String 类来存储字符串,还可以使用 StringBuilder 类或 StringBuffer 类存储字符串,那么它们之间有什么区别呢? String 类具有是不可变 ...
- C++之路进阶——边表
边表:利用边的关系来表示一个图. 用到数组: head//head[i]表示从i点出发的第一条边的编号; next[i]//与第i条边起点相同的下一条边的编号; a[i]//第i条边的终点; val[ ...
- centOS6.6升级gcc4.8
最近想升级mesos0.23.0,结果编译mesos0.23.0需要gcc4.8+,可是centOS6.6最高版本的gcc也只到4.4.7版本,只好手动升级一下了. 下载4.8.2源码 wget ft ...