SlideShare a Scribd company logo
My two cents about
Mysql backup
Aleksandrs Asafovs
MySQL 5 Database Administrator
Oracle Database 11g Administrator Certified Master
Oracle9i Database Administrator Certified Professional
Oracle Database 10g Administrator Certified Professional
Oracle Database 11g Administrator Certified Professional
Oracle Database 12c Administrator Certified Professional
Oracle9i Database Administrator Certified Professional - Special Accreditation:
Managing Oracle9i on Linux
Oracle RAC 11g Release 2 and Grid Infrastructure Administration
Oracle Database 10g Real Application Clusters Administrator Certified Expert
Oracle Application Server 10g Administrator Certified Associate
Oracle Weblogic Server 11g: System Administration I
Certified Ethical Hacker(CEH)
About me
My name is Aleksandrs Asafovs
Working with Oracle for over 15 years
MySQL 5 years
My two cents about Mysql backup
Certificate experts 200+
Competence
5
8 GB RAM
35 GB database
SSD disk
Environment
Oracle VM 5.1.8
Oracle Linux 7.2
MySql 5.7.14
6
Environment
7
SQL Dump
mysqldump -u root -p --databases stream1 > backup-test-file.sql
#procedure or function
mysqldump -u root -p --databases stream1 --routines > backup-test-file.sql
#Users + point in time recovery
mysqldump -u root -p --databases mysql > backup-test-file.sql
mysqldump -u root -p --databases stream1 --single-transaction --routines
--master-data=2> backup-test-mysql.sql
8
SQL Dump
Full DB
Backup
Restore
with
bin_logs
Restore
without
binlogs
Sql Dump 20m 1h36m 1h04m
File size 28G*
*The size before we use any compression,
After pigz compression 3.0G
9
File system snapshot
Logical Volume Manager(LVM)
#!/bin/sh
#make snapshot script , execute manually
#script freeze DB, flush buffers , crate snapshot , then unfreeze DB
echo "Flushing tables"
/usr/bin/mysql --login-path=/backup/user_l -e "FLUSH TABLES WITH READ LOCK;"
echo "Syncing"
/bin/sync
echo "Show master status"
/usr/bin/mysql --login-path=/backup/user_l -e "SHOW MASTER STATUS;"
echo "Creating snapshot"
/sbin/lvcreate -L1G -s -n dbsnapshot /dev/ol/home
echo "Unlocking tables"
/usr/bin/mysql --login-path=/backup/user_l -e "UNLOCK TABLES;"
echo "Mounting filesystem "
mount /dev/ol/dbsnapshot /snapshot/ -onouuid,ro
10
File system snapshot
Logical Volume Manager(LVM)
Demo_1
dsmc ba image -snapshotproviderimage=none /dev/ol/dbsnapshot
dsmc rest image /dev/ol/dbsnapshot
11
Percona
XtraBackup
Install Percona XtraBackup
https://www.percona.com/software/mysql-database/percona-xtrabackup
Create user for backup
mysql> CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 's3cret';
mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost';
DEMO_2
12
Percona
XtraBackup
innobackupex --login-path=/backup/user_l 
--no-timestamp 
--stream=xbstream 
--history=$(date +%d-%m-%Y-%H-%M) /mysql/backups/full > 
/mysql/backups/full/full-backup_$(date +%d-%m-%Y-%H-%M).xbstream 2> 
/mysql/backups/full/full-backup-progress_$(date +%d-%m-%Y-%H-%M).log &
Full Backup
13
Percona
XtraBackup
innobackupex --login-path=/backup/user_l 
--no-timestamp 
--use-memory=1G 
--stream=xbstream 
--parallel=4 
--incremental 
--incremental-history-name=$(date +%d-%m-%Y-%H-%M) 
--history=$(date +%d-%m-%Y-%H-%M) /mysql/backups/full > 
/mysql/backups/full/incremental-$(date +%H)-mysqlbackup$(date +%d-%m-%Y-%H-%M).xbstream 2> 
/mysql/backups/full/incbackup_progress$(date +%d-%m-%Y-%H-%M).log &
xbstream -x < incremental.xbstream
Incremental Backup
--incremental-history-name: Searches the PERCONA_SCHEMA.XtraBackup_history table for the mostrecent backup record containing t
the defined name value, and then starts the backup using its innodb_to_lsn value.
14
Percona
XtraBackup
prepare: full backup
innobackupex --login-path=/backup/user_l --apply-log --redo-only /mysql/backups/full --use-memory=1G
prepare: inc 1 day
innobackupex --apply-log --redo-only /mysql/backups/full --incremental-dir=/mysql/backups/mon/
prepare: inc 2 day
innobackupex --apply-log --redo-only /mysql/backups/full --incremental-dir=/mysql/backups/tue/
prepare: apply log
innobackupex --apply-log /mysql/backups/full
15
Percona
XtraBackup
Restore Database
innobackupex --copy-back /mysql/backups/full
Change mysql folder permissions
chown -R mysql:mysql /var/lib/mysql
16
Percona
XtraBackup
Partial Backup
innobackupex --login-path=/backup/user_l 
--include='^stream[.]vod_log ' /mysql/backups/one_table
Prepare
innobackupex --apply-log --export /mysql/backups/one_table
17
Percona
XtraBackupCompress adn Encrypt
innobackupex --defaults-file=/etc/mysql/backup-my.cnf 
--no-timestamp 
--use-memory=1G 
--stream=xbstream 
--parallel=4 
--encrypt=AES256 
--encrypt-key-file=/etc/mysql/.mykeyfile 
--encrypt-threads=4 
--compress 
--compress-threads=4 
--history=$(date +%d-%m-%Y) ./ > 
mysqlbackup$(date +%d-%m-%Y).qp.xbc.xbs 2> 
backup-progress.log &
• Send it to another server
$ innobackupex --stream=tar ./ | ssh user@desthost "cat - > /data/backups/backup.tar"
18
No single backup optionversion 5.7
• Filesystem cold backup
• Datadir
• innodb_data_home_dir
• innodb_data_file_path
• innodb_undo_directory
• innodb_temp_data_file_path
• Log-bin
• My.cnf
• http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html
19
Full DB
Backup
Restore
with
bin_logs
Restore
without
binlogs
Sql Dump 20m 1h36m 1h04m
Percona
XtraBackup
5m 5m
Percona
XtraBackup
20
MySQL Enterprise $Backup
Download from
https://edelivery.oracle.com
Create user
CREATE USER 'mysqlbackup'@'localhost' IDENTIFIED BY 'new-password';
GRANT RELOAD ON *.* TO 'mysqlbackup'@'localhost';
GRANT CREATE, INSERT, DROP, UPDATE ON mysql.backup_progress TO 'mysqlbackup'@'localhost';
GRANT CREATE, INSERT, SELECT, DROP, UPDATE ON mysql.backup_history TO 'mysqlbackup'@'localhost';
GRANT REPLICATION CLIENT ON *.* TO 'mysqlbackup'@'localhost';
GRANT SUPER ON *.* TO 'mysqlbackup'@'localhost';
GRANT PROCESS ON *.* TO 'mysqlbackup'@'localhost';
mysqlbackup is copying InnoDBtables, reads and writes to both InnoDB and
 MyISAM tables can continue. During the copying of MyISAM tables, reads (but not writes)
 to those tables are permitted.
21
MySQL Enterprise Backup
FULL DB BACKUP(37G)
./mysqlbackup --login-path=/backup/user_l --host=127.0.0.1 
--backup-image=/mysql/ent_back/$(hostname)_mysql.mbi 
--backup-dir=/mysql/ent_files backup-to-image
Incremental backup
./mysqlbackup --login-path=/backup/user_l --host=127.0.0.1
--incremental --incremental-base=history:last_backup --backup-dir=/mysql/ent_inc2
--backup-image=/mysql/ent_back/$(hostname)_incremental_$(date +%d-%m-%Y-%H-%M).mbi backup-to-image
22
MySQL Enterprise Backup
FULL DB RESTORE
./mysqlbackup --datadir=/mysql/mysql/ --backup-image=/mysql/ent_back/localhost.localdomain_mysql.mbi
--backup-dir=/mysql/restore-tmp copy-back-and-apply-log
Incremental backup
./mysqlbackup --datadir=/mysql/mysql/
--backup-image=/mysql/ent_back/localhost.localdomain_incremental_06-11-2016-23-33.mbi
--backup-dir=/mysql/restore-tmp --incremental copy-back-and-apply-log
23
MySQL Enterprise Backup
Include table1 and table2
--include-tables=^test.table[12]$
Exclude table1 and table2
--exclude-tables=^mydb.t[12]$
* selective restore is only supported for backups created using transportable tablespaces (TTS)
24
MySQL Enterprise Backup
Symantec NetBackup
IBM Tivoli Storage Manager
Oracle Secure Backup
Tivoli Storage Manager
./mysqlbackup --port=3307 --protocol=tcp --user=backup_user --password=foobar 
--backup-image=sbt:my-first-backup --sbt-lib-path=/usr/lib/libobk.so 
--sbt-environment="TDPO_OPTFILE=/path/to/my/tdpo.opt" --backup-dir=/path/to/my/dir backup-to-ima
https://blogs.oracle.com/svetasmirnova/entry/story_of_success_mysql_enterprise?cm_mc_uid=30726269129114773169864&cm_mc_sid_50200000=1478294216
25
MySQL Enterprise Backup
mysqlbackup --backup-image=/backups/image.enc --encrypt 
--key=23D987F3A047B475C900127148F9E0394857983645192874A2B3049570C12A34 
--backup-dir=/var/tmp/backup backup-to-image
To use a key file for the same task:
mysqlbackup --backup-image=/backups/image.enc 
--encrypt --key-file=/meb/key --backup-dir=/var/tmp/backup backup-to-image
To decrypt a backup when extracting it:
mysqlbackup --backup-image=/backups/image.enc
--decrypt --key-file=/meb/key --backup-dir=/backups/extract-dir extract
26
Point in time Recovery
Mysqldump ---master-data=2
LVM_snapshot
27
Point in time Recovery
MySQL Enterprise Backup
Percona XtraBackup
28
Point in time Recovery
mysqlbinlog mysql-bin.000001 --start-position=11872 
--stop-datetime="2016-11-6 16:00:00"
29
TIME
https://www.mysql.com/products/enterprise/backup.html
30
Full DB
Backup
Restore
with
bin_logs
Restore
without
binlogs
Sql Dump 20m 1h36m 1h04m
Percona
XtraBackup
5m 5m
MySQL
Enterprise
Backup
5m 4m
TIME
31
Conclusion--Incremental
Xtrabackup
This procedure only affects XtraDB or InnoDB-based tables.
Other tables with a different storage engine, e.g. MyISAM,
will be copied entirely each time an incremental backup is performed.
MysqlEnterprise
For non-InnoDB files, the entire file is included in an incremental backup
if that file has changed since the previous backup, which means the savings for
backup resources are less significant when comparing with the case with InnoDB tables.
Thank You!
Aleksandrs Asafovs
Mob. +371 28353668
ASAFOVS@GMAIL.COM
Q & A

More Related Content

PDF
MySQL Backup and Recovery Essentials
PDF
The History and Future of the MySQL ecosystem
PDF
Backing Up the MySQL Database
PDF
MySQL Backup & Recovery
PDF
Meb Backup & Recovery Performance
PDF
MySQL Backup and Security Best Practices
PDF
Monitoring your technology stack with New Relic
PDF
MySQL Scalability Mistakes - OTN
MySQL Backup and Recovery Essentials
The History and Future of the MySQL ecosystem
Backing Up the MySQL Database
MySQL Backup & Recovery
Meb Backup & Recovery Performance
MySQL Backup and Security Best Practices
Monitoring your technology stack with New Relic
MySQL Scalability Mistakes - OTN

What's hot (20)

PDF
MySQL Enterprise Backup (MEB)
PDF
Lessons Learned Managing Large AWS Environments
PDF
MySQL Enterprise Backup: PITR Partial Online Recovery
PDF
MySQL Replication: Demo Réplica en Español
PDF
MySQL's new Secure by Default Install -- All Things Open October 20th 2015
PDF
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
PDF
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
DOCX
Upgrading mysql version 5.5.30 to 5.6.10
PDF
MySQL :What's New #GIDS16
PDF
MySQL Enterprise Backup
PDF
MySQL For Oracle DBA's and Developers
PDF
MySQL Enterprise Backup - BnR Scenarios
PPTX
MySQL8.0_performance_schema.pptx
DOCX
My sql storage engines
PDF
MySQL Enterprise Backup & Oracle Secure Backup
PPTX
ProxySQL para mysql
PDF
MySQL Best Practices - OTN
PDF
MySQL Server Backup, Restoration, and Disaster Recovery Planning
PPTX
MySQL DBA
DOCX
Mater,slave on mysql
MySQL Enterprise Backup (MEB)
Lessons Learned Managing Large AWS Environments
MySQL Enterprise Backup: PITR Partial Online Recovery
MySQL Replication: Demo Réplica en Español
MySQL's new Secure by Default Install -- All Things Open October 20th 2015
MySQL High Availability and Disaster Recovery with Continuent, a VMware company
Embracing Database Diversity: The New Oracle / MySQL DBA - UKOUG
Upgrading mysql version 5.5.30 to 5.6.10
MySQL :What's New #GIDS16
MySQL Enterprise Backup
MySQL For Oracle DBA's and Developers
MySQL Enterprise Backup - BnR Scenarios
MySQL8.0_performance_schema.pptx
My sql storage engines
MySQL Enterprise Backup & Oracle Secure Backup
ProxySQL para mysql
MySQL Best Practices - OTN
MySQL Server Backup, Restoration, and Disaster Recovery Planning
MySQL DBA
Mater,slave on mysql
Ad

Viewers also liked (9)

PDF
MySQL enterprise edition backup
PDF
Uc2010 xtra backup-hot-backups-and-more
PDF
Tracking Page Changes for Your Database and Bitmap Backups
PDF
Zararfa SummerCamp 2012 - Performing fast backups in large scale environments...
PDF
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackup
PDF
MySQL Enterprise Backup
PDF
Fast Incremental Backups with Percona Server and Percona XtraBackup / PLMCE 2014
PDF
Highly efficient backups with percona xtrabackup
PDF
Online MySQL Backups with Percona XtraBackup
MySQL enterprise edition backup
Uc2010 xtra backup-hot-backups-and-more
Tracking Page Changes for Your Database and Bitmap Backups
Zararfa SummerCamp 2012 - Performing fast backups in large scale environments...
PLAM 2015 - Evolving Backups Strategy, Devploying pyxbackup
MySQL Enterprise Backup
Fast Incremental Backups with Percona Server and Percona XtraBackup / PLMCE 2014
Highly efficient backups with percona xtrabackup
Online MySQL Backups with Percona XtraBackup
Ad

Similar to My two cents about Mysql backup (20)

PDF
MySQL for Oracle DBAs
PPT
Mysql
PDF
Intro ProxySQL
PPTX
Building cloud stack at scale
ODP
MySQL 101 PHPTek 2017
PPT
Architecting cloud
PDF
MySQL Replication Basics -Ohio Linux Fest 2016
PPT
Basic Knowledge on MySql Replication
PPTX
Making MySQL highly available using Oracle Grid Infrastructure
ODP
Mysql
PDF
Installing oracle grid infrastructure and database 12c r1
PDF
My sql monitoring cu沙龙
PPTX
RAC-Installing your First Cluster and Database
DOCX
Physical_Standby_Database_R12.2.4
PDF
Whitepaper MS SQL Server on Linux
PDF
Multiple instances on linux
PPTX
MySQL Replication Overview -- PHPTek 2016
PPT
Oreilly Webcast Jan 09, 2009
PDF
MySQL Replication Update -- Zendcon 2016
DOC
X64服务器 lnmp服务器部署标准 new
MySQL for Oracle DBAs
Mysql
Intro ProxySQL
Building cloud stack at scale
MySQL 101 PHPTek 2017
Architecting cloud
MySQL Replication Basics -Ohio Linux Fest 2016
Basic Knowledge on MySql Replication
Making MySQL highly available using Oracle Grid Infrastructure
Mysql
Installing oracle grid infrastructure and database 12c r1
My sql monitoring cu沙龙
RAC-Installing your First Cluster and Database
Physical_Standby_Database_R12.2.4
Whitepaper MS SQL Server on Linux
Multiple instances on linux
MySQL Replication Overview -- PHPTek 2016
Oreilly Webcast Jan 09, 2009
MySQL Replication Update -- Zendcon 2016
X64服务器 lnmp服务器部署标准 new

More from Andrejs Vorobjovs (20)

PDF
Peteris Arajs - Where is my data
PPTX
Maksims Greckis - Trace File Analyzer
PDF
Aleksejs Nemirovskis - Manage your data using oracle BDA
PPTX
LVOUG meetup #18
PPTX
LVOUG meetup #17
PPTX
LVOUG meetup #16
PDF
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
PPT
Top 15 MySQL parameters
PDF
Riga Dev Day vestule
PDF
Rdd2016 featured talks
PDF
Rdd2016 flyer
PDF
meetup #15
PDF
OTN tour 2015 press release in Russian
PPTX
OTN tour 2015, 100miles
PDF
OTN tour 2015 benchmarking oracle io performance with Orion by Alex Gorbachev
PPTX
OTN tour 2015 Oracle Enterprise Manager 12c – Proof of Concept
PDF
OTN tour Oracle db Cloud by Alex Gorbachev
PDF
OTN tour 2015 Experience in implementing SSL between oracle db and oracle cli...
PDF
OTN tour 2015 AWR data mining
PDF
OTN tour 2015 opening speech
Peteris Arajs - Where is my data
Maksims Greckis - Trace File Analyzer
Aleksejs Nemirovskis - Manage your data using oracle BDA
LVOUG meetup #18
LVOUG meetup #17
LVOUG meetup #16
Middleware upgrade to Oracle Fusion Middleware(FMW) 12c.Real Case stories.
Top 15 MySQL parameters
Riga Dev Day vestule
Rdd2016 featured talks
Rdd2016 flyer
meetup #15
OTN tour 2015 press release in Russian
OTN tour 2015, 100miles
OTN tour 2015 benchmarking oracle io performance with Orion by Alex Gorbachev
OTN tour 2015 Oracle Enterprise Manager 12c – Proof of Concept
OTN tour Oracle db Cloud by Alex Gorbachev
OTN tour 2015 Experience in implementing SSL between oracle db and oracle cli...
OTN tour 2015 AWR data mining
OTN tour 2015 opening speech

Recently uploaded (20)

PPTX
GDM (1) (1).pptx small presentation for students
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
Insiders guide to clinical Medicine.pdf
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
01-Introduction-to-Information-Management.pdf
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PPTX
Cell Types and Its function , kingdom of life
PPTX
Lesson notes of climatology university.
PPTX
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
master seminar digital applications in india
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
Classroom Observation Tools for Teachers
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Institutional Correction lecture only . . .
GDM (1) (1).pptx small presentation for students
Abdominal Access Techniques with Prof. Dr. R K Mishra
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
Insiders guide to clinical Medicine.pdf
STATICS OF THE RIGID BODIES Hibbelers.pdf
01-Introduction-to-Information-Management.pdf
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Module 4: Burden of Disease Tutorial Slides S2 2025
Cell Types and Its function , kingdom of life
Lesson notes of climatology university.
PPT- ENG7_QUARTER1_LESSON1_WEEK1. IMAGERY -DESCRIPTIONS pptx.pptx
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
master seminar digital applications in india
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Classroom Observation Tools for Teachers
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Institutional Correction lecture only . . .

My two cents about Mysql backup

  • 1. My two cents about Mysql backup Aleksandrs Asafovs
  • 2. MySQL 5 Database Administrator Oracle Database 11g Administrator Certified Master Oracle9i Database Administrator Certified Professional Oracle Database 10g Administrator Certified Professional Oracle Database 11g Administrator Certified Professional Oracle Database 12c Administrator Certified Professional Oracle9i Database Administrator Certified Professional - Special Accreditation: Managing Oracle9i on Linux Oracle RAC 11g Release 2 and Grid Infrastructure Administration Oracle Database 10g Real Application Clusters Administrator Certified Expert Oracle Application Server 10g Administrator Certified Associate Oracle Weblogic Server 11g: System Administration I Certified Ethical Hacker(CEH) About me My name is Aleksandrs Asafovs Working with Oracle for over 15 years MySQL 5 years
  • 5. 5 8 GB RAM 35 GB database SSD disk Environment Oracle VM 5.1.8 Oracle Linux 7.2 MySql 5.7.14
  • 7. 7 SQL Dump mysqldump -u root -p --databases stream1 > backup-test-file.sql #procedure or function mysqldump -u root -p --databases stream1 --routines > backup-test-file.sql #Users + point in time recovery mysqldump -u root -p --databases mysql > backup-test-file.sql mysqldump -u root -p --databases stream1 --single-transaction --routines --master-data=2> backup-test-mysql.sql
  • 8. 8 SQL Dump Full DB Backup Restore with bin_logs Restore without binlogs Sql Dump 20m 1h36m 1h04m File size 28G* *The size before we use any compression, After pigz compression 3.0G
  • 9. 9 File system snapshot Logical Volume Manager(LVM) #!/bin/sh #make snapshot script , execute manually #script freeze DB, flush buffers , crate snapshot , then unfreeze DB echo "Flushing tables" /usr/bin/mysql --login-path=/backup/user_l -e "FLUSH TABLES WITH READ LOCK;" echo "Syncing" /bin/sync echo "Show master status" /usr/bin/mysql --login-path=/backup/user_l -e "SHOW MASTER STATUS;" echo "Creating snapshot" /sbin/lvcreate -L1G -s -n dbsnapshot /dev/ol/home echo "Unlocking tables" /usr/bin/mysql --login-path=/backup/user_l -e "UNLOCK TABLES;" echo "Mounting filesystem " mount /dev/ol/dbsnapshot /snapshot/ -onouuid,ro
  • 10. 10 File system snapshot Logical Volume Manager(LVM) Demo_1 dsmc ba image -snapshotproviderimage=none /dev/ol/dbsnapshot dsmc rest image /dev/ol/dbsnapshot
  • 11. 11 Percona XtraBackup Install Percona XtraBackup https://www.percona.com/software/mysql-database/percona-xtrabackup Create user for backup mysql> CREATE USER 'bkpuser'@'localhost' IDENTIFIED BY 's3cret'; mysql> GRANT RELOAD, LOCK TABLES, REPLICATION CLIENT ON *.* TO 'bkpuser'@'localhost'; DEMO_2
  • 12. 12 Percona XtraBackup innobackupex --login-path=/backup/user_l --no-timestamp --stream=xbstream --history=$(date +%d-%m-%Y-%H-%M) /mysql/backups/full > /mysql/backups/full/full-backup_$(date +%d-%m-%Y-%H-%M).xbstream 2> /mysql/backups/full/full-backup-progress_$(date +%d-%m-%Y-%H-%M).log & Full Backup
  • 13. 13 Percona XtraBackup innobackupex --login-path=/backup/user_l --no-timestamp --use-memory=1G --stream=xbstream --parallel=4 --incremental --incremental-history-name=$(date +%d-%m-%Y-%H-%M) --history=$(date +%d-%m-%Y-%H-%M) /mysql/backups/full > /mysql/backups/full/incremental-$(date +%H)-mysqlbackup$(date +%d-%m-%Y-%H-%M).xbstream 2> /mysql/backups/full/incbackup_progress$(date +%d-%m-%Y-%H-%M).log & xbstream -x < incremental.xbstream Incremental Backup --incremental-history-name: Searches the PERCONA_SCHEMA.XtraBackup_history table for the mostrecent backup record containing t the defined name value, and then starts the backup using its innodb_to_lsn value.
  • 14. 14 Percona XtraBackup prepare: full backup innobackupex --login-path=/backup/user_l --apply-log --redo-only /mysql/backups/full --use-memory=1G prepare: inc 1 day innobackupex --apply-log --redo-only /mysql/backups/full --incremental-dir=/mysql/backups/mon/ prepare: inc 2 day innobackupex --apply-log --redo-only /mysql/backups/full --incremental-dir=/mysql/backups/tue/ prepare: apply log innobackupex --apply-log /mysql/backups/full
  • 15. 15 Percona XtraBackup Restore Database innobackupex --copy-back /mysql/backups/full Change mysql folder permissions chown -R mysql:mysql /var/lib/mysql
  • 16. 16 Percona XtraBackup Partial Backup innobackupex --login-path=/backup/user_l --include='^stream[.]vod_log ' /mysql/backups/one_table Prepare innobackupex --apply-log --export /mysql/backups/one_table
  • 17. 17 Percona XtraBackupCompress adn Encrypt innobackupex --defaults-file=/etc/mysql/backup-my.cnf --no-timestamp --use-memory=1G --stream=xbstream --parallel=4 --encrypt=AES256 --encrypt-key-file=/etc/mysql/.mykeyfile --encrypt-threads=4 --compress --compress-threads=4 --history=$(date +%d-%m-%Y) ./ > mysqlbackup$(date +%d-%m-%Y).qp.xbc.xbs 2> backup-progress.log & • Send it to another server $ innobackupex --stream=tar ./ | ssh user@desthost "cat - > /data/backups/backup.tar"
  • 18. 18 No single backup optionversion 5.7 • Filesystem cold backup • Datadir • innodb_data_home_dir • innodb_data_file_path • innodb_undo_directory • innodb_temp_data_file_path • Log-bin • My.cnf • http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html
  • 19. 19 Full DB Backup Restore with bin_logs Restore without binlogs Sql Dump 20m 1h36m 1h04m Percona XtraBackup 5m 5m Percona XtraBackup
  • 20. 20 MySQL Enterprise $Backup Download from https://edelivery.oracle.com Create user CREATE USER 'mysqlbackup'@'localhost' IDENTIFIED BY 'new-password'; GRANT RELOAD ON *.* TO 'mysqlbackup'@'localhost'; GRANT CREATE, INSERT, DROP, UPDATE ON mysql.backup_progress TO 'mysqlbackup'@'localhost'; GRANT CREATE, INSERT, SELECT, DROP, UPDATE ON mysql.backup_history TO 'mysqlbackup'@'localhost'; GRANT REPLICATION CLIENT ON *.* TO 'mysqlbackup'@'localhost'; GRANT SUPER ON *.* TO 'mysqlbackup'@'localhost'; GRANT PROCESS ON *.* TO 'mysqlbackup'@'localhost'; mysqlbackup is copying InnoDBtables, reads and writes to both InnoDB and  MyISAM tables can continue. During the copying of MyISAM tables, reads (but not writes)  to those tables are permitted.
  • 21. 21 MySQL Enterprise Backup FULL DB BACKUP(37G) ./mysqlbackup --login-path=/backup/user_l --host=127.0.0.1 --backup-image=/mysql/ent_back/$(hostname)_mysql.mbi --backup-dir=/mysql/ent_files backup-to-image Incremental backup ./mysqlbackup --login-path=/backup/user_l --host=127.0.0.1 --incremental --incremental-base=history:last_backup --backup-dir=/mysql/ent_inc2 --backup-image=/mysql/ent_back/$(hostname)_incremental_$(date +%d-%m-%Y-%H-%M).mbi backup-to-image
  • 22. 22 MySQL Enterprise Backup FULL DB RESTORE ./mysqlbackup --datadir=/mysql/mysql/ --backup-image=/mysql/ent_back/localhost.localdomain_mysql.mbi --backup-dir=/mysql/restore-tmp copy-back-and-apply-log Incremental backup ./mysqlbackup --datadir=/mysql/mysql/ --backup-image=/mysql/ent_back/localhost.localdomain_incremental_06-11-2016-23-33.mbi --backup-dir=/mysql/restore-tmp --incremental copy-back-and-apply-log
  • 23. 23 MySQL Enterprise Backup Include table1 and table2 --include-tables=^test.table[12]$ Exclude table1 and table2 --exclude-tables=^mydb.t[12]$ * selective restore is only supported for backups created using transportable tablespaces (TTS)
  • 24. 24 MySQL Enterprise Backup Symantec NetBackup IBM Tivoli Storage Manager Oracle Secure Backup Tivoli Storage Manager ./mysqlbackup --port=3307 --protocol=tcp --user=backup_user --password=foobar --backup-image=sbt:my-first-backup --sbt-lib-path=/usr/lib/libobk.so --sbt-environment="TDPO_OPTFILE=/path/to/my/tdpo.opt" --backup-dir=/path/to/my/dir backup-to-ima https://blogs.oracle.com/svetasmirnova/entry/story_of_success_mysql_enterprise?cm_mc_uid=30726269129114773169864&cm_mc_sid_50200000=1478294216
  • 25. 25 MySQL Enterprise Backup mysqlbackup --backup-image=/backups/image.enc --encrypt --key=23D987F3A047B475C900127148F9E0394857983645192874A2B3049570C12A34 --backup-dir=/var/tmp/backup backup-to-image To use a key file for the same task: mysqlbackup --backup-image=/backups/image.enc --encrypt --key-file=/meb/key --backup-dir=/var/tmp/backup backup-to-image To decrypt a backup when extracting it: mysqlbackup --backup-image=/backups/image.enc --decrypt --key-file=/meb/key --backup-dir=/backups/extract-dir extract
  • 26. 26 Point in time Recovery Mysqldump ---master-data=2 LVM_snapshot
  • 27. 27 Point in time Recovery MySQL Enterprise Backup Percona XtraBackup
  • 28. 28 Point in time Recovery mysqlbinlog mysql-bin.000001 --start-position=11872 --stop-datetime="2016-11-6 16:00:00"
  • 30. 30 Full DB Backup Restore with bin_logs Restore without binlogs Sql Dump 20m 1h36m 1h04m Percona XtraBackup 5m 5m MySQL Enterprise Backup 5m 4m TIME
  • 31. 31 Conclusion--Incremental Xtrabackup This procedure only affects XtraDB or InnoDB-based tables. Other tables with a different storage engine, e.g. MyISAM, will be copied entirely each time an incremental backup is performed. MysqlEnterprise For non-InnoDB files, the entire file is included in an incremental backup if that file has changed since the previous backup, which means the savings for backup resources are less significant when comparing with the case with InnoDB tables.
  • 32. Thank You! Aleksandrs Asafovs Mob. +371 28353668 ASAFOVS@GMAIL.COM Q & A

Editor's Notes

  • #13: innobackupex --login-path=/backup/user_l /mysql/backups/full --no-timestamp ---full backup innobackupex --login-path=/backup/user_l --incremental --incremental-basedir=/mysql/backups/full /mysql/backups/mon ---incremental backup
  • #18: From percona documentation