"Disaster is inevitable" and "To move forward you must first backup" should be known to all software developers. This presentation will discuss all the options for your valuable data assets in MySQL, and highlight how to maintain site reliability of your data
1. MySQL
Backup & Recovery
Essentials
Ronald Bradford
http://ronaldbradford.com
Buenos Aires, Argentina
2013-10
EffectiveMySQL.com - Performance, Scalability & Business Continuity
2. "No one cares if you can
backup, only that you
can restore."
Adapted from W. Curtis Preston - Backup & Recovery (O'Reilly 2009)
EffectiveMySQL.com - Performance, Scalability & Business Continuity
3. Agenda
Backup Options
Tools available
Restore Options
Necessary Nomenclature
Business Requirements
Slides at http://j.mp/EM-BandR
EffectiveMySQL.com - Performance, Scalability & Business Continuity
4. ABOUT AUTHOR
Ronald Bradford
All time top MySQL blogger
Published Author (4++ books)
Oracle ACE Director
MySQL community member of the year (2009 & 2013)
24 years of RDBMS experience,14 years with MySQL
MySQL Inc (2006-2008)
Oracle Corporation (1996-1999)
EffectiveMySQL.com - Performance, Scalability & Business Continuity
8. Verification
Necessary at EVERY step
3
Commands complete without error
No errors in logs
Results match expectations
Approximate
Precise
EffectiveMySQL.com - Performance, Scalability & Business Continuity
9. Testing
4
“Testing is about trying to
break your software, not
checking that it works!”
Ronald Bradford, circa 2006
EffectiveMySQL.com - Performance, Scalability & Business Continuity
10. "MySQL has no single
unbreakable backup
solution [yet]."
EffectiveMySQL.com - Performance, Scalability & Business Continuity
13. EXAMPLE DB
SELECT
FROM
SUM(data_length+index_length)/1024/1024 AS total_mb,
SUM(data_length)/1024/1024 AS data_mb,
SUM(index_length)/1024/1024 AS index_mb,
COUNT(DISTINCT table_schema) AS schema_cnt,
COUNT(*) AS tables,
CURDATE() AS today,
VERSION()
information_schema.tablesG
*************************** 1. row ***************************
total_mb: 5344.63
data_mb: 4545.49
index_mb: 799.13
TIP: Your daily verification
schema_cnt: 7
step should include this
tables: 103
today: 2012-04-03
VERSION(): 5.1.61-0ubuntu0.11.10.1-log
Available on GitHub with Effective
MySQL: Backup and Recovery Book
EffectiveMySQL.com - Performance, Scalability & Business Continuity
22. Backup Options
File Copy
Cons
MySQL unavailable
Not consistent (**)
Time to warm server caches
Restore must match configuration
Must backup right files
EffectiveMySQL.com - Performance, Scalability & Business Continuity
26. Backup Options
SNAPSHOT
Cons
Must be pre-configured (LVM)
Extra Disk I/O
Inconsistent (*)
FLUSH TABLES duration
EffectiveMySQL.com - Performance, Scalability & Business Continuity
27. Backup Options
SNAPSHOT USAGE
$
$
$
$
$
$
sudo su sync ; lvcreate -L1G -s -n dbsnapshot /dev/db/p0
mkdir -p /mnt/dbsnapshot
mount -o ro /dev/db/dbsnapshot /mnt/dbsnapshot
du -sh /mnt/dbsnapshot
ls -al /mnt/dbsnapshot
$ mkdir /mysql/backup/snapshot1
$ cp -r /mnt/dbsnapshot/* /mysql/backup/snapshot1
$ sudo su $ mylvmbackup
TIP: mylvmbackup does all the
hard work
http://effectiveMySQL.com/article/configuring-a-new-hard-drive-for-lvm
http://effectiveMySQL.com/article/using-mysql-with-lvm
http://www.lenzg.net/mylvmbackup/
EffectiveMySQL.com - Performance, Scalability & Business Continuity
39. Backup needs
Static Backup
Useless without Binary Log position
mysql> SHOW MASTER STATUSG
File: mysql-bin.020616
Position: 63395562
Binlog_Do_DB:
Binlog_Ignore_DB:
WARNING: Can work on
slave and provide the wrong
information
EffectiveMySQL.com - Performance, Scalability & Business Continuity
44. Compression
Utility
Comp (s)
Dec (s)
Saving
lzo (-3)
pigz (-1)
pigz [-6]
gzip [-6]
bzip2
lzo (-9)
lzma
xz
21
43
105
232
540
20m
58m
59m
34
33
25
78
175
82
180
160
48%
64%
69%
69%
74%
58%
78%
78%
Depends greatly on data types
EffectiveMySQL.com - Performance, Scalability & Business Continuity
45. Terminology
MTTD - Mean Time To Detect
MTTR - Mean Time to Recover
RPO - Recovery Point Objective
RDO - Recovery Data Objective
SLA - Service Level Agreement
Determining business priorities is
important for any strategy
EffectiveMySQL.com - Performance, Scalability & Business Continuity
47. CONCLUsiON
This is an introduction
Advance features are important
Best option depends
Replication is important in your strategy
Test, Test, Test. - “Chaos Monkey”
Slides at http://j.mp/EM-BandR
EffectiveMySQL.com - Performance, Scalability & Business Continuity