- XtraBackup
- XtraBackup 버전
- 설치
- 백업/복구 실행
- 증분 백업/복구 실행
XtraBackup
Percona에서 무료로 제공하는 database 핫 백업 도구 입니다.
XtraBackup 버전
XtraBackup 버전 | MySQL 버전 |
---|---|
동작 않음, MariaBackup 사용 권장 | MariaDB 10.3 |
일부 비정상 동작 | MariaDB 10.2 |
8.0 | 8.0 |
2.4 | 5.7 |
2.0 ~ 2.4 | 5.6 |
2.0 ~ 2.4 | 5.5 |
2.0 | 5.1 |
설치
OS : CentOS 7
DB : MariaDB 5.5
XtraBackup 2.3.6
yum -y install percona-xtrabackup
xtrabackup --version
# xtrabackup version 2.3.6 based on MySQL server 5.6.24 Linux (x86_64) (revision id: )
vi /etc/my.cnf
[mysqld]
innodb_log_file_size=5M
[xtrabackup]
datadir=/var/lib/mysql
target_dir=/work/backup/
chown -R mysql: /etc/my.cnf
백업/복구 실행
#--- 백업
innobackupex --defaults-file=/etc/my.cnf --user=root --password=비밀번호 --no-lock /work/backup/
ls -alF /work/backup/
#--- 복구
systemctl stop mariadb.service
rm -rf /var/lib/mysql/*
innobackupex --defaults-file=/etc/my.cnf --copy-back /work/backup/2020-02-02_22-39-54
chown -R mysql: /var/lib/mysql/*
ls -alF /var/lib/mysql/*
systemctl start mariadb.service
증분 백업/복구 실행
#--- Full 백업
xtrabackup --defaults-file=/etc/my.cnf --backup --user=root --password=비밀번호 --no-lock --target-dir=/work/backup/fullbackup/
ls -alF /work/backup/
#--- Incremental(증분) 백업
xtrabackup --defaults-file=/etc/my.cnf --backup --user=root --password=비밀번호 --no-lock --target-dir=/work/backup/incremental_20200202/ --incremental-basedir=/work/backup/fullbackup/
xtrabackup --defaults-file=/etc/my.cnf --backup --user=root --password=비밀번호 --no-lock --target-dir=/work/backup/incremental_20200203/ --incremental-basedir=/work/backup/incremental_20200202/
#--- 복구 준비
xtrabackup --prepare --apply-log-only --target-dir=/work/backup/fullbackup/
xtrabackup --prepare --apply-log-only --target-dir=/work/backup/fullbackup/ --incremental-dir=/work/backup/incremental_20200202/
xtrabackup --prepare --apply-log-only --target-dir=/work/backup/fullbackup/ --incremental-dir=/work/backup/incremental_20200203/
#--- 복구
cd /work/backup/fullbackup/
rsync -rvt --exclude 'xtrabackup_checkpoints' --exclude 'xtrabackup_logfile' ./ /var/lib/mysql
chown -R mysql:mysql /var/lib/mysql/
#--- Binary log로 복구
mysqlbinlog --start-datetime="2020-02-02 01:00:00" --stop-datetime="2020-02-02 16:00:00" mysql-bin.000541 >> restore.log
mysql -u~ -p~ ${DATABASE} < restore.log
Last modified, 2020.02.02 ~ 2020.02.02, version 0.01
최종 수정일: 2024-09-30 12:26:18
이전글 :
다음글 :