Backuping Full Database
Posted by Ricardo Santos in backup, database, mysql, scripts, zabbixon Sep 21st, 2012 | 3 comments
Dump doesn’t work. If you have huge tables with billions of rows your backup process could become a nightmare, mainly if you need to restore it.
This method aims to perform a full backup of a large MySQL database, as Zabbix (any version), focusing on a fast recovery from disaster. So I chose XtraBackup for this task, a backup tool from Percona, which works using the hotcopy mode.
First, you need to download and install XtraBackup:
http://www.percona.com/downloads/XtraBackup/LATEST/
http://www.percona.com/downloads/XtraBackup/LATEST/
XtraBackup offers a lot of parameters, so this script is intented to be the simplest possible.
Make sure that you’re using InnoDB for history tables at least. In my case, I have a Zabbix Database with 300GB data that takes about 3 hours to do all backup.
Create script /var/lib/xtrabackup/mysql-fullbackup.sh:
Adjust the permissions:
Configure your crontab to backup every day at 04:15am:
So if you need a restore, it’s very simple:
1
2
3
4
5
6
7
8
9
10
|
# stop MySQL
service mysql stop
# move backuped files
cd /var/lib
mv mysql mysqlcrashed
mv xtrabackup/lastbackup mysql
# start MySQL
service mysql start
|
No comments:
Post a Comment