gpcrondump備份命令翻譯筆記(GreenPlum)

把一個數據庫備份成SQL腳本文件,該腳本文件可以用gpdbrestore命令來恢復數據庫。


摘要
gpcrondump -x database_name 
   [-s schema | -t schema.table | -T schema.table] 
   [--table-file=filename | --exclude-table-file=filename] 
   [-u backup_directory] [-R post_dump_script] [--incremental] 
   [-K timestamp [--list-backup-files] ]
   [--prefix prefix_string [--list-filter-tables] [-c] [-z] [-r] 
   [-f free_space_percent] [-b] [-h] [-j | -k] [-g] [-G] [-C] 
   [-d master_data_directory] [-B parallel_processes] [-a] [-q]
   [-y reportfile] [-l logfile_directory] [-v]
   { [-E encoding] [--inserts | --column-inserts] [--oids] 
     [--no-owner | --use-set-session-authorization] [--no-privileges] 
     [--rsyncable]
     [--ddboost [--replicate --max-streams max_IO_streams
     [--ddboost-skip-ping] ] ] }


gpcrondump --ddboost-host ddboost_hostname
   [--ddboost-host ddboost_hostname ... ]
   --ddboost-user ddboost_user --ddboost-backupdir backup_directory 
   [--ddboost-remote] [--ddboost-skip-ping] 


gpcrondump --ddboost-config-remove


gpcrondump -o


gpcrondump -? 
目錄
gpcrondump --version


描述
gpcrondump命令把一個數據庫的內容備份到一個SQL腳本文件中,這可以在之後用gpdbrestore命令恢復數據庫對象定義和用戶數據。
在備份期間,用戶仍然可以正常訪問該備份數據庫。


默認的,在各個節點被命名爲db_dumps/時間戳的目錄下創建備份文件,默認備份的數據文件是通過gzip的形式壓縮。


gpcrondump允許你用crontab計劃程序命令來備份一個gp數據庫(crontab是linux下的一個計劃程序設置命令)。
crontab對gpcrondump執行腳本的計劃應該部署在gp的master主節點上。


警告:用gpcrondump命令備份數據庫的同時,修改表可能會造成gpcrondump失敗。


數據域加速
gpcrondump被用於調度數據域加速備份和還原操作。gpcrondump還可用於爲數據域加速設置或清除一次時間憑證。


重要提醒:增量備份不支持數據域加速。如果你計劃創建增量備份而不是完全備份,不可以使用帶數據域加速的完全備份。


返回的狀態碼
下面是gpcrondump命令返回的狀態碼清單


0-無任何差錯備份完成
1-備份完成,但有一個或以上的警告產生
2-備份失敗,致命的錯誤


郵件通知
爲了獲取gpcrondump發送電子郵件狀態通知,你必須在GP的超級用戶(gpadmin)主目錄或和gpcrondump命令同一個目錄中($GPHOME/bin)放置一個名爲mail_contacts的文件。
這個文件每行應該包含一個電子郵件地址。如果不能查找到mail_contacts文件在其中任一位置中,gpcrondump將發出警告。
如果兩個地方都包含有mail_contacts文件,那麼GP的超級用戶(gpadmin)主目錄下的文件優先使用。


選項
-a (do not prompt) 不提示用戶確認


-b (bypass disk space check) 忽略磁盤空間檢查。除非--ddboost被指定,否則默認是檢查磁盤可用空間的。當使用數據域加速時,這個選項是始終啓用的。


注:忽略可用磁盤空間檢查將生成警告消息。有該警告消息,如果備份成功,gpcrondump命令則返回狀態碼爲1。(如果備份失敗,所有情況都將返回狀態碼爲2)。


-B parallel_processes 並行處理 節點的數量以並行的方式來檢查前後備份驗證。如果沒有指定,gpcrondump將啓動多達60個並行處理,這取決於有多少個節點實例需要備份。


-c (clear old dump files first)指定此選項,備份前將先刪除老的備份文件。在db_dumps備份目錄,目錄名稱日期是最早的將被刪除。如果目錄名稱是當前日期,則該目錄不會被刪除。
默認是不刪除舊的備份文件。刪除的目錄可能包含來自一個或多個備份文件。


警告:使用此選項之前,需確保增量備份執行恢復未被刪除。gpdbrestore命令選項--list-backup列出需要備份的備份集進行備份。


如果--ddboost選項被指定,僅數據域加速(Data Domain Boost)中舊的文件會被刪除。
此選項不支持與-u選項一起用。


-C (clean catalog before restore) 恢復數據庫對象之前清理目錄schema。gpcrondump創建備份文件時添加drop命令到SQL腳本文件中。 
當SQL腳本文件被gpdbrestore命令用來恢復數據庫對象時,裏面的drop命令在恢復前會刪除已經存在的數據庫對象。
如果--incremental選項被指定,並且文件是NFS格式存儲的,則-C選項是不支持的。
如果指定-C選項,數據庫對象是不被刪除的。


--column-inserts 備份數據將是帶有列名的INSERT命令集 如果--incremental選項被指定,該選項也是不支持的。


-d master_data_directory master主節點數據目錄。如果沒指定,將使用$MASTER_DATA_DIRECTORY變量對應目錄。


--ddboost [--replicate --max-streams max_IO_streams [--ddboost-skip-ping] ]
爲此備份使用數據域加速。在使用數據域加速之前,建立數據域加速憑證作爲下面下一個選項的描述。


如果--ddboost選項被指定,以下是推薦選項。
-z option (uncompressed)
Backup compression (turned on by default) should be turned off with the -z option. 
Data Domain Boost will deduplicate and compress the backup data before sending it to the Data Domain system.
備份壓縮(默認開啓)應該用-z選項關閉。在把它發送數據域系統之前,ddboost選項將不復制並壓縮備份數據。
--replicate --max-streams max_IO_streams 可選項 如果指定此選項,gpcrondump將在主數據域服務器備份完成後,在遠程數據域服務器上覆製備份。

max_IO_streams指定域的最大數目的數據I/O流    

gpcrondump replicates the backup on the remote Data Domain server after the backup is complete on the primary Data Domain server. max_IO_streams specifies the maximum number of Data Domain I/O streams that can be used when replicating the backup set on the remote Data Domain server from the primary Data Domain server.

You can use gpmfr to replicate a backup if replicating a backup with gpcrondump takes a long time and prevents other backups from occurring. Only one instance of gpcrondump can be running at a time. While gpcrondump is being used to replicate a backup, it cannot be used to create a backup.

You can run a mixed backup that writes to both a local disk and Data Domain. If you want to use a backup directory on your local disk other than the default, use the –u option. For more information about mixed backups and Data Domain Boost, see “Backing Up and Restoring Databases” in the Greenplum Database Administrator Guide.

If --incremental is specified, this option is not supported.

Important: Never use the Greenplum Database default backup options with Data Domain Boost. Also, incremental backups are not supported with Data Domain Boost. You cannot use the Data Domain Boost options with a full backup if you plan to perform incremental backups.

To maximize Data Domain deduplication benefits, retain at least 30 days of backups.

Note: The -b, -c, -f, -G, -g, -R, and -u options change if --ddboost is specified. See the options for details.
--ddboost-host ddboost_hostname
[--ddboost-host ddboost_hostname ...] --ddboost-user ddboost_user --ddboost-backupdir backup_directory
[--ddboost-remote][--ddboost-skip-ping]
Sets the Data Domain Boost credentials. Do not combine this optionswith any other gpcrondump options. Do not enter just one part of thisoption.
ddboost_hostname is the IP address (or hostname associated to the IP) of the host. There is a 30-character limit. If you use two or more network connections to connect to the Data Domain system, specify each connection with the --ddboost-host option.
ddboost_user is the Data Domain Boost user name. There is a 30-character limit.
backup_directory is the location for the backup files, configuration files, and global objects on the Data Domain system. The location on the system is GPDB/backup_directory.
--ddboost-remote is optional. Indicates that the configuration parameters are for the remote Data Domain system that is used for backup replication Data Domain Boost managed file replication.
For example:
gpcrondump --ddboost-host 192.0.2.230 --ddboost-user ddboostusername --ddboost-backupdir gp_production
After running gpcrondump with these options, thesystem verifies the limits on the host and user names and prompts forthe Data Domain Boost password. Enter the password when prompted; thepassword is not echoed on the screen. There is a 40-character limit onthe password that can include lowercase letters (a-z), uppercase letters(A-Z), numbers (0-9), and special characters ($, %, #, +, etc.).
The system verifies the password. After the password is verified,the system creates encrypted DDBOOST_CONFIG files in the user’s homedirectory.
In the example, the --ddboost-backupdir option specifiesthe backup directory gp_production in the Data Domain Storage Unit GPDB.
Note: If there is more than one operating system user using Data Domain Boost for backup and restore operations, repeat this configuration process for each of those users.
Important: Set up the Data Domain Boost credential before running any Data Domain Boost backups with the --ddboost option, described above.
--ddboost-config-remove
Removes all Data Domain Boost credentials from the master and allsegments on the system. Do not enter this option with any other gpcrondumpoption.
--ddboost-skip-ping
Specify this option to skip the ping of a Data Domain system. Whenworking with a Data Domain system, ping is used to ensure that the DataDomain system is reachable. If the Data Domain system is configured toblock ICMP ping probes, specify this option.
-E encoding
Character set encoding of dumped data. Defaults to the encoding ofthe database being dumped. See the Greenplum Database Reference Guidefor the list of supported character sets.
-f free_space_percent
When checking that there is enough free disk space to create the dump files, specifies a percentage of free disk space that should remain after the dump completes. The default is 10 percent.

This is option is not supported if --ddboost or --incremental is specified.

-g (copy config files)
Secure a copy of the master and segment configuration files postgresql.conf,pg_ident.conf, and pg_hba.conf. Theseconfiguration files are dumped in the master or segment data directoryto db_dumps/YYYYMMDD/config_files_<timestamp>.tar.
If --ddboost is specified, the backup is locatedon the default storage unit in the directory specified by --ddboost-backupdirwhen the Data Domain Boost credentials were set.
-G (dump global objects)
Use pg_dumpall to dump global objects such as rolesand tablespaces. Global objects are dumped in the master data directoryto db_dumps/YYYYMMDD/gp_global_1_1_<timestamp>.
If --ddboost is specified, the backup is locatedon the default storage unit in the directory specified by --ddboost-backupdirwhen the Data Domain Boost credentials were set.
-h (record dump details)
Record details of database dump in database table public.gpcrondump_historyin database supplied via -x option. Utility will createtable if it does not currently exist.
--incremental (backup changes to append-optimizedtables)
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 one of the following operations was performed on the table after the last backup.

ALTER TABLE INSERT DELETE UPDATE TRUNCATE DROP and then re-create the tableFor 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: Incremental backup cannot be used with Data Domain Boost. You cannot use the Data Domain Boost options with a full backup if you plan to perform incremental backups.
--inserts
Dump data as INSERT, rather than COPYcommands.
If --incremental is specified, this optionis not supported.
-j (vacuum before dump)
Run VACUUM before the dump starts.
-K timestamp [--list-backup-files]
Specify the timestamp that is used when creatinga backup. The timestamp is 14-digit string that specifiesa date and time in the format yyyymmddhhmmss. The date is used for backupdirectory name. The date and time is used in the backup file names. If-K timestamp is not specified, a timestampis generated based on the system time.
When adding a backup to set of backups, gpcrondumpreturns an error if the timestamp does not specify adate and time that is more recent than all other backups in the set.
--list-backup-files is optional. When you specifyboth this option and the -K timestampoption, gpcrondump does not perform a backup. gpcrondumpcreates two text files that contain the names of the files that willbe created when gpcrondump backs up a Greenplum database.The text files are created in the same location as the backup files.
The file names use the timestamp specified by the-K timestamp option and have the suffix_pipes and _regular_files. For example:
gp_dump_20130514093000_pipes
gp_dump_20130514093000_regular_files
The _pipes file contains a list of file names that becan be created as named pipes. When gpcrondump performsa backup, the backup files will generate into the named pipes. The _regular_filesfile contains a list of backup files that must remain regular files.gpcrondump and gpdbrestore use theinformation in the regular files during backup and restore operations.To backup a complete set of Greenplum Database backup files, the fileslisted in the _regular_files file must also be backedup after the completion of the backup job.
To use named pipes for a backup, you need to create the named pipeson all the Greenplum Database and make them writeable before runninggpcrondump.
If --ddboost is specified, -K timestamp[--list-backup-files] is not supported.
-k (vacuum after dump)
Run VACUUM after the dump has completed successfully.
-l logfile_directory
The directory to write the log file. Defaults to ~/gpAdminLogs.
--no-owner
Do not output commands to set object ownership.
--no-privileges
Do not output commands to set object privileges (GRANT/REVOKEcommands).
-o (clear old dump files only)
Clear out old dump files only, but do not run a dump. This will removethe oldest dump directory except the current date’s dump directory.All dump sets within that directory will be removed.
Warning: Before using this option, ensure that incremental backupsrequired to perform the restore are not deleted. The gpdbrestoreutility option --list-backup lists the backup sets requiredto perform a restore.
If --ddboost is specified, only the old fileson Data Domain Boost are deleted.
If --incremental is specified, this optionis not supported.
--oids
Include object identifiers (oid) in dump data.
If --incremental is specified, this optionis not supported.
--prefix prefix_string [--list-filter-tables]
Prepends prefix_string followed by an underscorecharacter (_) to the names of all the backup files created during a backup.
--list-filter-tables is optional. When you specifyboth options, gpcrondump does not perform a backup.For the full backup created by gpcrondump that is identifiedby the prefix-string, the tables that were includedor excluded for the backup are listed. You must also specify the --incrementaloption if you specify the --list-filter-tables option.
If --ddboost is specified, --prefixprefix_string[--list-filter-tables] is not supported.
-q (no screen output)
Run in quiet mode. Command output is not displayed on the screen,but is still written to the log file.
-r (rollback on failure)
Rollback the dump files (delete a partial dump) if a failure is detected. The default is to not rollback.
Note: This option is not supported if --ddboost is specified.
-R post_dump_script
The absolute path of a script to run after a successful dump operation.For example, you might want a script that moves completed dump filesto a backup host. This script must reside in the same location on themaster and all segment hosts.
--rsyncable
Passes the --rsyncable flag to the gziputility to synchronize the output occasionally, based on the input duringcompression. This synchronization increases the file size by less than1% in most cases. When this flag is passed, the rsync(1)program can synchronize compressed files much more efficiently. The gunziputility cannot differentiate between a compressed file created with thisoption, and one created without it.
-s schema_name
Dump only the named schema in the named database.
If --incremental is specified, this optionis not supported.
-t schema.table_name
Dump only the named table in this database. The -toption can be specified multiple times. If you want to specify multipletables, you can also use the --table-file=filenameoption in order not to exceed the maximum token limit.
If --incremental is specified, this optionis not supported.
-T schema.table_name
A table name to exclude from the database dump. The -Toption can be specified multiple times. If you want to specify multipletables, you can also use the --exclude-table-file=filenameoption in order not to exceed the maximum token limit.
If --incremental is specified, this optionis not supported.
--exclude-table-file=filename
Excludes all tables listed in the filename from the databasedump. The file filename contains any number of tables, listedone per line.
If --incremental is specified, this optionis not supported.
--table-file=filename
Dumps only the tables listed in the filename. The file filenamecontains any number of tables, listed one per line.
If --incremental is specified, this optionis not supported.
-u backup_directory
Specifies the absolute path where the backup files will be placedon 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 tobe backed up. Using this option may be desirable if each segment hosthas multiple segment instances as it will create the dump files in acentralized 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 ofALTER OWNER commands to set object ownership.
-v | --verbose
Specifies verbose mode.
--version (show utility version)
Displays the version of this utility.
-x database_name
Required. The name of the Greenplum database to dump. Multiple databasescan be specified in a comma-separated list.
-y reportfile
This option is deprecated and will be removed in a future release.If specified, a warning message is returned stating that the -yoption is deprecated.
Specifies the full path name where a copy of the backup job log fileis placed on the master host. The job log file is created in the masterdata directory or if running remotely, the current working directory.
-z (no compression)
Do not use compression. Default is to compress the dump files usinggzip.
We recommend this option (-z) be used for NFS andData Domain Boost backups.
-? (help)
Displays the online help.

Examples

Call gpcrondump directly and dump mydatabase (and global objects):

gpcrondump -x mydatabase -c -g -G

A crontab entry that runs a backup of the sales database (and global objects) nightly at one past midnight:

01 0 * * * /home/gpadmin/gpdump.sh >> gpdump.log
The content of dump script gpdump.sh is:
#!/bin/bash
  export GPHOME=/usr/local/greenplum-db
  export MASTER_DATA_DIRECTORY=/data/gpdb_p1/gp-1
  . $GPHOME/greenplum_path.sh  
  gpcrondump -x sales -c -g -G -a -q 

This example creates two text files, one with the suffix _pipes and the other with _regular_files. The _pipes file contain the file names that can be named pipes when you backup the Greenplum database mytestdb.

gpcrondump -x mytestdb -K 20131030140000 --list-backup-files

To use incremental backup with a set of database tables, you must createa full backup of the set of tables and specify the --prefixoption to identify the backup set. The following example uses the --table-fileoption to create a full backup of the set of files listed in the fileuser-tables. The prefix user_backupidentifies the backup set.

gpcrondump -x mydatabase --table-file=user-tables
  --prefix user_backup

To create an incremental backup for the full backup created in the previousexample, specify the --incremental option and the option--prefix user_backup to identify backup set. This examplecreates an incremental backup.

gpcrondump -x mydatabase --incremental --prefix user_backup

This command lists the tables that were included or excluded for the fullbackup.

gpcrondump -x mydatabase --incremental --prefix user_backup 
--list-filter-tables

參考原文鏈接地址:

http://gpdb.docs.pivotal.io/4320/utility_guide/admin_utilities/gpcrondump.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章