Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Percona Live London 2014 - MySQL Backup Strategy @ IEDR

21,400 views

Published on

Slides from my talk about MySQL Backups @ Percona Live London 2014

Published in: Internet
  • Be the first to comment

Percona Live London 2014 - MySQL Backup Strategy @ IEDR

  1. 1. MySQL Backup Strategy @ IEDR Marcelo Altmann Oracle Certified Professional, MySQL 5 Database Administrator Oracle Certified Professional, MySQL 5 Developer Percona Live London – November 2014
  2. 2. Who am I ?  MySQL Database Administrator @ IE Domain Registry (IEDR)  Student  Systems for Internet @ FEEVALE University  Oracle Certified Professional  MySQL 5 Database Administrator  MySQL 5 Developer  marceloaltmann.com  @altmannmarcelo
  3. 3. What IEDR Does ?  Manages the official country code top level domain for Ireland - .ie  Maintain the database of .ie registered domain names  MySQL 5.6  Mainly InnoDB  ~80% reads
  4. 4. Backup Introduction – What for ?  Add new slave to your replication topology  Reproduce some bug on your labs  Point-in-time recovery  Disaster Recovery
  5. 5. Backup Introduction - Replication as backup  Replication is a backup, but not for all scenarios:  When is replication a backup ?  Physical file corruption  Any Master Server component fail ( RAM, Disk, Network, CPU )
  6. 6. Backup Introduction – Replication as backup  Including OS errors
  7. 7. Backup Introduction – When Replication doesn’t works as a backup?  Application bugs  Someone hacks into your database server  Wrong admin commands like DELETE / UPDATE / DROP
  8. 8. Backup - Logical  Logical  Save information represented as logical structure ( CREATE DATABASE, CREATE TABLE, INSERT )  Can be used to restore all databases, single database, single table  Slower than Physical  It's taken while MySQL is running  Done via mysqldump, mydumper, SELECT ... INTO OUTFILE
  9. 9. Backup - Physical  Raw copies of directory and files of database contents (copy of MySQL datadir)  No selective restore  Faster than Logical  Done via OS copy commands, mysqlbackup, mysqlhotcopy, percona xtrabackup
  10. 10. Backup life cycle Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  11. 11. Backup - Infrastructure
  12. 12. Backup - Infrastructure
  13. 13. Logical Backup Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  14. 14. Logical Backup  mysqldump  Store backup duration  Backup output of SHOW SLAVE STATUSG  Verify exit status and last line of the dump
  15. 15. Logical Backup – exit status and last line Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  16. 16. Logical Backup – exit status and last line
  17. 17. Logical Backup – exit status and last line
  18. 18. Logical Backup – Compress and Encrypt Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  19. 19. Logical Backup – Compress and Encrypt  Change file permissions  Compress backup to save disk space (GZIP, BZIP2, …)  Encrypt your backups ( openssl )
  20. 20. Logical Backup – Compress and Encrypt
  21. 21. Distribute – Same Server Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  22. 22. Distribute – Same Server
  23. 23. Distribute – Same DC
  24. 24. Distribute – Same Region
  25. 25. Distribute
  26. 26. Distribute  Send copy of your backups to different datacenter  Pay attention on the distance between datacenters – Natural Disasters!  scp / rsync  Keep copy for 1 week
  27. 27. Restore Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  28. 28. Restore  Drop everything on MySQL restore instance  Restore dump  Check exit status of mysql command
  29. 29. Physical Backup – Fast Recovery Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  30. 30. Physical Backup – Fast Recovery  Stop MySQL  Compress datadir  Encrypt file
  31. 31. Slave Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  32. 32. Slave
  33. 33. Slave  Configure restore server as slave  Use --master-data  Use --relay-log-info-repository=TABLE  Use Relay_Master_Log_File and Exec_Master_Log_Pos from SHOW SLAVE STATUS  Use GTID
  34. 34. Checksum Backup (Logical) Verify Encrypt Distribute Restore Checksum Slave Backup (Physical)
  35. 35. Checksum  Verify data integrity between master and slaves  pt-table-checksum  Monitor time
  36. 36. Backup binlog - Point in time recovery  mysqlbinlog –-raw –-read-from-remote-server –-stop-never  Checksum master binlog and backup binlog  Compress  Encrypt
  37. 37. Audit Copy  Allows you to restore your database to any point in time  Grouped by month  First Logical and Physical backup of each month  All binary logs
  38. 38. Questions? @altmannmarcelo marceloaltmann.com

×