Upload
nataly-polyanskaya
View
3.447
Download
1
Tags:
Embed Size (px)
DESCRIPTION
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.
Citation preview
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon1
Everything about backups
Dmitry Kuzmenko
IBSurgeon
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon2
Backup methods
• gbak
• nbackup/online dump
• scripts
• stop server and copy
• no backups
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon3
Rescue plan
• what is a failure
• how many data will be lost
• how long company can wait
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon4
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 © 2009 – Dmitry Kuzmenko, IBSurgeon5
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 © 2009 – Dmitry Kuzmenko, IBSurgeon6
GBAK in depth
• backup speed
• restore speed
• flaws
• goods
• usage
• tools
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon7
Backup speed
Ya FB 1.5 FB 2.0 IB 7.5 IB 2007
0:000:140:28
0:430:571:12
1:261:401:552:09
2:242:382:52
3:073:213:36
3:504:044:19
4:334:485:02
5:165:315:45
6:006:146:28
6:436:577:127:26
7:407:558:09
localhostlocal
servapi
se same hd
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon8
single processor (core)
FB 1.5
0:00
0:14
0:28
0:43
0:57
1:12
1:26
1:40
1:55
2:09
2:24
2:38
2:52
3:07
3:21
3:36
3:50
4:04
4:19
4:33
4:48
5:02
5:16
5:31
5:45
6:00
6:14
6:28
6:43
localhostlocal
servapi
se same hd
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon9
2 cores
FB 1.5 FB2.1 FB2.1cs IB 2007
0:00
0:36
1:12
1:48
2:24
3:00
3:36
4:12
4:48
5:24
6:00
6:36
7:12
7:48
8:24
9:00
9:36
10:12
10:48
11:24
12:00
12:36
13:12
13:48
14:24
15:00
15:36
16:12
16:48
17:24
18:00
localhostlocal
servapi
se same hd
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon10
• 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 © 2009 – Dmitry Kuzmenko, IBSurgeon11
Restore speed
• database 3.8gb– backup – 4 minutes, 15 minutes worst case– restore - ~1 hour.
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon12
Non-restorable backups
• why?
• how to fix it?
• best script
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon13
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 © 2009 – Dmitry Kuzmenko, IBSurgeon14
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 © 2009 – Dmitry Kuzmenko, IBSurgeon15
NBACKUP in depth
• backup speed
• restore speed
• flaws
• goods
• usage
• tools
• InterBase dump
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon16
NBACKUP
• LOCK
• Changes goes to delta
• Copying
• Applying delta to DB
DATABASE
Delta
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon17
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 © 2009 – Dmitry Kuzmenko, IBSurgeon18
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 © 2009 – Dmitry Kuzmenko, IBSurgeon19
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 © 2009 – Dmitry Kuzmenko, IBSurgeon20
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 © 2009 – Dmitry Kuzmenko, IBSurgeon21
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 © 2009 – Dmitry Kuzmenko, IBSurgeon22
NBackup sample 1
• 50 users, 10 hours per day, 68k transactions per day, accounting• hourly nbackup – 1-2 minutes, total nbackups – 40gb (year)
5700
220
120
25
0 2000 4000 6000
Size
level 3 hour
level 2 day
level 1 week
Database
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon23
NBackup sample 2
• 100 users, 12 hours per day, 224k transactions per day, stock• hourly nbackup – 1-2 minutes
10000
1000
800
300
0 5000 10000 15000
Size
level 3 hour
level 2 day
level 1 week
Database
www.FirebirdDevelopersDay.com.br © 2009 – Dmitry Kuzmenko, IBSurgeon24
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 © 2009 – Dmitry Kuzmenko, IBSurgeon25
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 © 2009 – Dmitry Kuzmenko, IBSurgeon26
• Questions?
• www.ib-aid.com