Skip to main content

Mysql Enterprise Backup - Incremental

we are going to test mysql incremental  backup using MEB Mysql Enterprise Backup


step1: I am taking full backup of all the existing database to image and compressing them

mysqlbackup --user=root --password=Mysql@1234 --backup-dir=/u02/backuptesting/fullbackup --compress  --backup-image=/u02/backuptesting/fullbackup/newbackup.mbi backup-to-image

step2:i am now creating a table backuptest in a test database and adding some data in to table 
use test;
CREATE TABLE backuptest (
  id_customer int(10),
  monthly_limit int(11),
  PRIMARY KEY (`id_customer`)
);

insert into test.backuptest (id_customer,monthly_limit) values ('1','2000');

Step 3: Now i am doing a  incremental backup in directory incremental-1
here i am giving incremental-base as  lastbackup history so it will keep base as last fullbackup taken.
mysqlbackup  --user=root --password=Mysql@1234 --incremental --incremental-base=history:last_backup --backup-dir=/u02/backuptesting/incremental-1 --compress --backup-image=/u02/backuptesting/incremental-1/mybackup-inc.mbi backup-to-image


Step 4:Now i am adding data again and taking another incremental backup incremental-2
insert into test.backuptest (id_customer,monthly_limit) values ('2','3000');
mysqlbackup  --user=root --password=Mysql@1234 --incremental --incremental-base=history:last_backup --backup-dir=/u02/backuptesting/incremental-2 --compress --backup-image=/u02/backuptesting/incremental-2/mybackup-inc.mbi backup-to-image


Step 5 :Now i am restoring the full backup taken to a directory fullinctest
restore the full backup to one location (/u02/backuptesting/fullinctest)
mysqlbackup  --defaults-file=/u02/backuptesting/fullbackup/backup-my.cnf  --datadir=/u02/backuptesting/fullinctest  --backup-image=/u02/backuptesting/fullbackup/newbackup.mbi  --backup-dir=/u02/backuptesting/temp --uncompress   copy-back-and-apply-log

Step 6:
restore  the incremental-1  backup on top of the previously restored full backup . so here --datadir is the location of the previously restored full backup
mysqlbackup  --defaults-file=/u02/backuptesting/incremental-1/backup-my.cnf --backup-image=/u02/backuptesting/incremental-1/mybackup-inc.mbi --incremental-backup-dir=/u02/backuptesting/temp2 --datadir=/u02/backuptesting/fullinctest --uncompress  --incremental copy-back-and-apply-log

Step 7:
Now  restore  the incremental-2  backup on top of the restoredbackup in step6 (i.e fullbackup + incremental-1) . so here --datadir=/u02/backuptesting/fullinctest it is the location of the previously restored full backup and incremantl-1 backup
mysqlbackup  --defaults-file=/u02/backuptesting/incremental-2/backup-my.cnf --backup-image=/u02/backuptesting/incremental-2/mybackup-inc.mbi --incremental-backup-dir=/u02/backuptesting/temp3 --datadir=/u02/backuptesting/fullinctest --uncompress  --incremental copy-back-and-apply-log

Now shutdown the mysql Service and replace the mysql directory with the  directory fullinctest (now fullinctest = fullbackup+incremental-1+incremental-2) and start the service.

check for the data
use test;
select * from backuptest:

+-------------+-------------------+
| id_customer | monthly_limit    |
+-------------+-------------------+
|           1 |             2000 |
|           2 |             3000 |
+-------------+-------------------+


Dis - advanatages with incremenatl backup:

1.)  if any of the incremenatl backup is corrupted then the subsequent restoration of other incrementl backup will fail .
2.)  In case of restoraion its time consuming to restore each and every incremental backup.





Comments