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 ...
随机推荐
- box2dweb基础
简介 大名鼎鼎的物理引擎box2d基本上大家都听说过,网上有两个javascript版本的box2d库,一个时box2djs,已经停止维护,一个是box2dweb.下面就来介绍一下box2dweb的基 ...
- MVC 登录认证与授权及读取登录错误码
最近悟出来一个道理,在这儿分享给大家:学历代表你的过去,能力代表你的现在,学习代表你的将来. 十年河东十年河西,莫欺少年穷 学无止境,精益求精 最近在自学MVC,遇到的问题很多,索性一点点总结下 ...
- NSCoding归档
大家都知道ios中数据持久化的方式有plist sqlite coredata nscoding 而nscoding不需要关心模型属性有多少个,是什么类型,不需要定义归档文件的规则. 下面给个类大家用 ...
- SQL top order between 一起使用
select * from emp;
- codevs 1204 寻找子串位置
http://codevs.cn/problem/1204/ 1204 寻找子串位置 时间限制: 1 s 空间限制: 128000 KB 题目等级 : 青铜 Bronze 题解 查看运行结果 ...
- linux tomcat 配置
http://www.cnblogs.com/xdp-gacl/p/4097608.html
- docker进入容器方法
更简单的,建议大家下载 .bashrc_docker,并将内容放到 .bashrc 中. $ wget -P ~ https://github.com/yeasy/docker_practice/ra ...
- Java实现找出数组中重复次数最多的元素以及个数
/**数组中元素重复最多的数 * @param array * @author shaobn * @param array */ public static void getMethod_4(int[ ...
- paper 72 :高动态范围(HDR)图像 HDR (High Dynamic Range)
In standard rendering, the red, green and blue values for a pixel are each represented by a fraction ...
- jq 选择器
基本选择器 1. id选择器(指定id元素)将id="one"的元素背景色设置为黑色.(id选择器返单个元素) $(document).ready(function () { ...