2013年6月16日星期日

備份和恢復MySQL的腳本使用Percona的innobackup Xtrabackup

Original post: http://anothermysqldba.blogspot.com/2013/06/backup-and-recovery-script-for-mysql.html

所以Percona的廣泛使用的備份工具Xtrabackup,他們意識到,每個人都經常使用這個工具在某種類型的腳本。 有一個頁面,談到: 


由於我最近做了一個例子,如何使用備份在以前的帖子 。 我想我還不如寫一個腳本顯示了如何腳本在備份過程。 再加上它已經多年,因為我寫在Python,所以我希望得到一點點的做法。 

因此,引進的代碼是下面,但我已經在github上放置腳本。 
這需要進行更多的測試,但隨時檢查代碼庫,更新和編輯。 

一旦代碼被測試了,我可以更新的例子,但我想成為這個項目從一開始就開放。 

因為它是在早期階段,我會建議使用 - showcommands = 1選項,所以你可以看到代碼計劃做什麼,也許嘗試這些命令。 顯然,它不應該被用於在生產系統中的評價。 


首先介紹: 

# ./backup_restore.py --help
Usage: backup_restore.py --process=[fullbackup,incremental,prepare,restore] --help --version --showcommands=1

This program enables you to backup full and incremental backups then prepare
and restore them using Percona's Xtrabackup

Options:
--version show program's version number and exit
-h, --help show this help message and exit
--process=PROCESS What would you like to do --process=
[fullbackup,incremental,prepare,restore]
--debug=DEBUG TURN DEBUG ON 1 OR OFF 0 OR VERBOSE 3
--showcommands=SHOWCOMMANDS
Shows the commands instead of executing them except
for the restore section because we go through that
step by step
--backup_root_directory=BACKUP_ROOT_DIRECTORY
THE ROOT DIRECTORY OF ALL YOUR BACKUPS, You can set
DEFAULT at start of the script
--percona_xtrabackup_location=PERCONA_XTRABACKUP_LOCATION
THE LOCATION OF YOUR xtrabackup FILE, You can set
DEFAULT at start of the script
--datadir=DATADIR MYSQL DATA DIR LOCATION, You can set DEFAULT at start
of the script
--username=DB_USERNAME
MySQL Username, You can set DEFAULT at start of the
script
--password=DB_PASSWORD
MySQL Password, You can set DEFAULT at start of the
script
--default_file=DEFAULT_FILE
MySQL my.cnf file location, You can set DEFAULT at
start of the script
--options=PERCONA_OPTIONS
Additional Options for innobackupex