I was hoping that someone here may be able to fill in a few blanks for me on the subject of online backups and archive logging. Basically the documentation I have found online thus far has allowed me to fumble my way through, but nothing has actually allowed me
understand what it going on, which I find very frustrating.
I switch to archive logging thus:
Code:
UPDATE DB CFG FOR TEST
USING logarchmeth1 "DISK:/db2archive/db2cq2/test"
logprimary 15 logsecond 10 logfilsiz 1000;
Now, I see that (in the default location) various logs are created over time, and these are referred to as the active logs. Fine and dandy. But eventually these active logs get relegated to archive logs and are moved by DB2 into the location I specified, something like the following: /db2archive/db2cq2/test/db2cq2/TEST/NODE0000/Cxxxxxxx/sxxxxxxx.LOG
I now go to make a full online backup:
Code:
BACKUP DATABASE TEST ONLINE
TO "/db2backup/db2cq2/test"
WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1 COMPRESS
INCLUDE LOGS
WITHOUT PROMPTING;
Now, I'm a bit confused as to exactly what logs are being included in the backup here. Is it all the currently active logs, or just logs of transactions that took place during the online backup, are archive logs factored in at all?
I now have:
- a database, with some active logs.
- a directory of archive logs
- an online backup for a given date
When I issue the following commands:
Code:
//restore
RESTORE DATABASE TEST
FROM "/db2backup/db2cq2/test" TAKEN AT date
LOGTARGET "/db2backup/db2cq2/test/restoredlogs"
WITH 2 BUFFERS BUFFER 1024 PARALLELISM 1
WITHOUT PROMPTING;
//rollforward
ROLLFORWARD DATABASE TEST
TO END OF LOGS AND COMPLETE;
The database is restored to the state of the backup and then rolled forward all the way back to the state it was in when I initiated the restore command in the first place, with no loss of data.
A few questions:
1) in the restore I specified a LOGTARGET, is this simply a temporary directory to restore the backed up log files to for use during the restore, and I can then safely delete these aftwards? What happens to these restored log files?
2) What happens log-wise when restoring a database to a previous state, are logs deleted, or is further logging created that shows that the database was restored from state x to state y?
3) If I take a weekly full online backup, with INCLUDE LOGS, am I right in saying that to restore the database to the point in time that the backup was taken I need nothing more than that backup file itself? If so, how would I restore the database to that point in time, my attempts to restore an online backup without rolling forward have proved unsuccessful thus far.
3) Can someone give me some context on Archive logs? These are logs no longer needed by DB2 apparently, but they play some part in being able to rollforward?
4) If the backup image includes logs then what role, if any, do the archived logs play when restoring a database?
5) Perhaps it wil be obvious to me if someone answers #3, but should you delete archived logs, and how do you determine which to delete & when?
I appreciate that's a lot of questions. If you've read this through to the end you probably deserve a break now
