Below is the simple script for taking non-blocking Mysql physical backup using percona xtrabackup toolkit. This backup is encrypted using AES256 algorithm.
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 36 37 38 39 40 41 42 43 44 45 46 47 | #!/bin/sh FILE=`$(date +%Y-%m-%d_%H_%M_%S)` BACKUPPATH=/home/db/backup CHECKPOINT=/home/db/lsns echo $FILE echo "Backup started on`date` " > /tmp/dbbkp.log xtrabackup --extra-lsndir=$CHECKPOINT/$FILE --encrypt=AES256 --encrypt-key="xzbhsicn2018jhjsjkg7trsv" --backup --user=bkp_usr --password='bkppwd@2018' --datadir=/var/lib/mysql -S /var/lib/mysql/mysql.sock --target-dir=$BACKUPPATH/$FILE if [ $? -eq 0 ]; then echo -e "Backup completed on `date`" >> /tmp/dbbkp.log else echo -e "Backup process failed" fi cd $BACKUPPATH echo $FILE echo -e "compressing backup file on `date`" >> /tmp/dbbkp.log tar -cv $FILE | gzip > $FILE.tar.gz if [ $? -eq 0 ]; then echo -e "file is successfully compressed on `date`" >> /tmp/dbbkp.log rm -rf $FILE else echo -e "issue happen while compressing file" >> /tmp/dbbkp.log fi echo "Database Backup "| mutt -s "Database backup completed successfully" xyz@gmail.com -a /tmp/dbbkp.log cd /tmp/` cd $BACKUPPATH FILE_TYPE="*.gz" find ${FILE_TYPE} -type f -mtime +7 -delete |
–extra-lsndir: save an extra copy of the xtrabackup_checkpoints and xtrabackup_info files in this directory.It can be used for the purpose of incremental backup
Backup can be decypt using below command –
1 | innobackupex --decrypt=AES256 --encrypt-key="xzbhsicn2018jhjsjkg7trsv" backup_folder |
Note:- for installing and restoring the backup , please go through with below shared link
“Mysql Physical Backup Using Percona Xtrbackup Tool”