Everything about backups (Firebird), by Dmitry Kuzmenko, CEO IBSurgeon

4,872 views

Published on

This is presentation from Firebird Developers Day 2009 in Brazil. Dmitry Kuzmenko is explaining the most important things every developer, administrator or IT Pro should know about Firebird approach for database backups. Backup speed, incremental backup and backup recovery are also covered.

Published in: Technology
0 Comments
2 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
4,872
On SlideShare
0
From Embeds
0
Number of Embeds
14
Actions
Shares
0
Downloads
94
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

Everything about backups (Firebird), by Dmitry Kuzmenko, CEO IBSurgeon

  1. 1. Everything about backups Dmitry Kuzmenko IBSurgeon www.FirebirdDevelopersDay.com.br 1 © 2009 – Dmitry Kuzmenko, IBSurgeon
  2. 2. Backup methods • gbak • nbackup/online dump • scripts • stop server and copy • no backups www.FirebirdDevelopersDay.com.br 2 © 2009 – Dmitry Kuzmenko, IBSurgeon
  3. 3. Rescue plan • what is a failure • how many data will be lost • how long company can wait www.FirebirdDevelopersDay.com.br 3 © 2009 – Dmitry Kuzmenko, IBSurgeon
  4. 4. Failure • Can happen at any time by any cause • Database corruption – light – can be corrected by gfix, IBFirstAid/FBFirstAid – hard – can be only restored from backup • Anyway, it takes time. How much? – gfix or FBFirstAid – depends on the database size, up to several hours – backup, gbak – several hours – nbackup – several minutes www.FirebirdDevelopersDay.com.br 4 © 2009 – Dmitry Kuzmenko, IBSurgeon
  5. 5. Resque plan • Choose appropriate backup type • Check restore time, multiply it by 2, since always things can go wrong • Try to understand how many data can be lost since last backup www.FirebirdDevelopersDay.com.br 5 © 2009 – Dmitry Kuzmenko, IBSurgeon
  6. 6. GBAK in depth • backup speed • restore speed • flaws • goods • usage • tools www.FirebirdDevelopersDay.com.br 6 © 2009 – Dmitry Kuzmenko, IBSurgeon
  7. 7. Backup speed localhost local servapi se same hd www.FirebirdDevelopersDay.com.br 7 © 2009 – Dmitry Kuzmenko, IBSurgeon
  8. 8. single processor (core) www.FirebirdDevelopersDay.com.br 8 © 2009 – Dmitry Kuzmenko, IBSurgeon
  9. 9. 2 cores localhost local servapi se same hd www.FirebirdDevelopersDay.com.br 9 © 2009 – Dmitry Kuzmenko, IBSurgeon
  10. 10. • Firebird 1.5, Interbase - do not use local protocol where processors or cores are more than one – use localhost or Services API instead, it's 2 times faster • Firebird 2.x local protocol does not have that problem www.FirebirdDevelopersDay.com.br 10 © 2009 – Dmitry Kuzmenko, IBSurgeon
  11. 11. Restore speed • database 3.8gb – backup – 4 minutes, 15 minutes worst case – restore - ~1 hour. www.FirebirdDevelopersDay.com.br 11 © 2009 – Dmitry Kuzmenko, IBSurgeon
  12. 12. Non-restorable backups • why? • how to fix it? • best script www.FirebirdDevelopersDay.com.br 12 © 2009 – Dmitry Kuzmenko, IBSurgeon
  13. 13. Non-restorable backup • broken primary keys – duplicate records • broken foreign keys or lost records in the reference tables – need to delete referencing records or to create records that were lost • broken backup file – IBBackupSurgeon www.FirebirdDevelopersDay.com.br 13 © 2009 – Dmitry Kuzmenko, IBSurgeon
  14. 14. Best backup/restore script • Check metadata – gbak –b –m, gbak –c – compare with dbcompare • backup, without garbage collection – gbak –b –g • test restore • always save metadata script – isql database.fdb –x >script.ddl www.FirebirdDevelopersDay.com.br 14 © 2009 – Dmitry Kuzmenko, IBSurgeon
  15. 15. NBACKUP in depth • backup speed • restore speed • flaws • goods • usage • tools • InterBase dump www.FirebirdDevelopersDay.com.br 15 © 2009 – Dmitry Kuzmenko, IBSurgeon
  16. 16. NBACKUP DATABASE • LOCK Delta • Changes goes to delta • Copying • Applying delta to DB www.FirebirdDevelopersDay.com.br 16 © 2009 – Dmitry Kuzmenko, IBSurgeon
  17. 17. backup speed • each nbackup run scans (reads) the whole database – same as database file copy speed • amount of writes depends on number of pages, changed from previous nbackup level www.FirebirdDevelopersDay.com.br 17 © 2009 – Dmitry Kuzmenko, IBSurgeon
  18. 18. restore speed • restore needs to – copy level 0 database (full file) to the original place – read all specified level backup files and write them to the database • so, restore speed is equal to copying all specified levels of nbackup from one place to another www.FirebirdDevelopersDay.com.br 18 © 2009 – Dmitry Kuzmenko, IBSurgeon
  19. 19. NBackup flaws • backup level 0 is a database, but you can't use it as database, until you "fix" it • if you "fix" database backup level 0, you can't add any levels (1-2-3) to it • you can't update database with level backups • nbackup of any level always scans (reads) the whole database • nbackup is a page copy. database damage is not controlled • ! on Classic, nbackup can freeze until some process commits changes to the database – this result longer time of nbackup than expected, and can cause delta file live for hours. During this time you can't make any nbackups www.FirebirdDevelopersDay.com.br 19 © 2009 – Dmitry Kuzmenko, IBSurgeon
  20. 20. NBackup is good • It is fast, as copying file – 6 minutes for 13gb database • you may organize levels for the needed rate • restore is also fast www.FirebirdDevelopersDay.com.br 20 © 2009 – Dmitry Kuzmenko, IBSurgeon
  21. 21. Common practice • level 0 – each month – level 1 – each week • level 2 – each day – level 3 – each 2 hours • monthly - kept the whole year • weekly – last 1-2 months • daily – last 1-2 weeks • hourly – 1 week • usually archives are compressed – not good, because decompression takes time www.FirebirdDevelopersDay.com.br 21 © 2009 – Dmitry Kuzmenko, IBSurgeon
  22. 22. NBackup sample 1 • 50 users, 10 hours per day, 68k transactions per day, accounting • hourly nbackup – 1-2 minutes, total nbackups – 40gb (year) 25 level 3 hour 120 level 2 day Size 220 level 1 week Database 5700 0 2000 4000 6000 www.FirebirdDevelopersDay.com.br 22 © 2009 – Dmitry Kuzmenko, IBSurgeon
  23. 23. NBackup sample 2 • 100 users, 12 hours per day, 224k transactions per day, stock • hourly nbackup – 1-2 minutes 300 level 3 hour 800 level 2 day Size 1000 level 1 week Database 10000 0 5000 10000 15000 www.FirebirdDevelopersDay.com.br 23 © 2009 – Dmitry Kuzmenko, IBSurgeon
  24. 24. InterBase dump • extention of gbak (-d option) • dump always increments "level 0" backup • database dump is a "read-only" database, ready to use • no dump "levels" • dumps can be made contigiously – dump db to db_dump each hour – dump db_dump to db_dump2 each day –… www.FirebirdDevelopersDay.com.br 24 © 2009 – Dmitry Kuzmenko, IBSurgeon
  25. 25. Scripts, replication, datapump • alternate methods of copying data • extracting scripts – check how long scripts will be "returned back to the database" • replication – may be the best, but needs additional hardware and expenses for the tools, triggers, etc. • IBPump, or your own tools www.FirebirdDevelopersDay.com.br 25 © 2009 – Dmitry Kuzmenko, IBSurgeon
  26. 26. • Questions? • www.ib-aid.com • support@ib-aid.com www.FirebirdDevelopersDay.com.br 26 © 2009 – Dmitry Kuzmenko, IBSurgeon

×