-
Notifications
You must be signed in to change notification settings - Fork 0
/
使用说明.txt
35 lines (24 loc) · 1.74 KB
/
使用说明.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
########## 参考 ##########
https://www.digitalocean.com/community/tutorials/how-to-configure-mysql-backups-with-percona-xtrabackup-on-ubuntu-16-04
########## 手动配置 ##########
sudo mkdir -p /data/backups
cd /data/backups
sudo git clone https://github.com/leewi9/mysql_incremental_backup.git
cd /data/backups/mysql_incremental_backup
sudo chmod +x install.sh
sudo ./install.sh
# 在备份脚本backup-mysql.sh中配置数据库的用户名和密码
########## 设置定时任务 ##########
# cron每1个小时运行一次
sudo crontab -e
0 */1 * * * sudo /data/backups/mysql_incremental_backup/backup-mysql.sh
########## 还原步骤 ##########
# 将脚本extract-mysql.sh拷贝至要还原的日期对应的文件夹,对文件进行解密,解密后的文件放在当前文件夹下的restore文件夹
sudo extract-mysql.sh *.xbstream
# 将脚本prepare-mysql.sh拷贝至restore文件夹,运行以准备数据
# To do so, you must be in the `restore` directory that contains the full- and any incremental- backups. The script will apply the changes from any incremental- directories onto the full- backup directory. Afterwards, it will apply the logs to create a consistent dataset that MySQL can use.
sudo prepare-mysql.sh
########### 注意点 ##########
必须要加--no-lock参数
在备份过程中,把INNODB数据文件备份完成后,会锁住整个库,并开始复制MYISAM等非事务引擎的数据和.frm;
所以如果你拥有比较多的MYISAM表,锁库的时候会持续很长。如果是在主库上运行,千万注意。