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的使用,如果有讲的不好的地方或错的地方,请大家务必扔板砖,要投准哦,砸死我算 ...
- MYBATIS报ORA-01745: 无效的主机/绑定变量名 异常
异常:Cause: java.sql.SQLSyntaxErrorException: ORA-01745: 无效的主机/绑定变量名 原因,sql语句中,两个填充变量间没有写逗号.
- Http错误 404.3-Not Found....或者500.19 Internal Server Error
解决方法:以管理员身份打开VS2010x64位兼容命令提示:aspnet_regiis -i
- java 笔记(4) —— java I/O 流、字节流、字符流
Java中使用流来处理程序的输入和输出操作,流是一个抽象的概念,封装了程序数据于输入输出设备交换的底层细节.JavaIO中又将流分为字节流和字符流,字节流主要用于处理诸如图像,音频视频等二进制格式数据 ...
- 别人写的一个Bootstrap系列教程
http://www.cnblogs.com/lansy/category/659061.html
- 理解运算符 || 和 && 及方法
|| 前面为true的话直接返回前面的值,前面为false的话返回后面的值.如下: console.log(0 || 1); console.log(1 || 0); console.log(1 || ...
- HTML部分标签和代码
1.1.1 一般标签.格式控制标签 所谓HTML就是 Hyper Text Markup Language(超无文本标记语言) <html> 开始标签 <head> 网页上 ...
- 树形DP(Holiday's Accommodation HDU4118)
题意:有n间房子,之间有n-1条道路连接,每个房间里住着一个人,这n个人都想到其他房间居住,并且每个房间不能有两个人,问所有人的路径之和最大是多少? 分析:对于每条边来说,经过改边的人由该边两端元素个 ...
- PHP5各个版本的新功能和新特性总结(转载 http://www.jb51.net/article/48150.htm)
本文目录:PHP5.2 以前:autoload, PDO 和 MySQLi, 类型约束PHP5.2:JSON 支持PHP5.3:弃用的功能,匿名函数,新增魔术方法,命名空间,后期静态绑定,Heredo ...
- 自建目录中jsp页面访问servlet路径出错404
---恢复内容开始--- 自建目录中jsp页面访问servlet路径出错404 使用eclipse建立的项目,总是会遇到路径问题,比如jsp页面访问servlet,jsp在默认的路径.jsp在自建目录 ...