Search code examples
loggingdb2resource-cleanup

about db2 log file archive and cleanup


I would like to start planning some disk cleanup for the machine where my db2 server is running now but it is not 100% clear how db2 might be affected when it comes to remove log files.

The configuration parameters for my db of interest says

Path To Log Files                          = /url_folder_log               
First log archive method (LOGARCHMETH1)    = DISK:/url_folder_arch
Log retain for recovery enable (LOGRETAIN) = OFF
Second log archive method   (LOGARCHMETH2) = OFF
User exit for logging enabled   (USEREXIT) = OFF

where /url_folder_arch is eating all the hard disk space.

As far as I understood (please correct me if I am wrong) db2 is backing up (better to say 'archiving') log files from /url_folder_log/ into /url_folder_arch while it is running and in background.

I am tempted to move the majority of oldest log files from /url_folder_arch to some backup storage: is it safe to do that?

When are these 'archive log files' are really used and might be necessary?

Reading it seems that logs are involved in 2 processes

  • database backup
  • rollforward recovery (for which my db seems NOT enabled).

If this is the case do I really need to keep all of those archive log files? At some point it might have the necessity also to delete these files.


Solution

  • It depends on your disaster recovery strategy. For example, some companies should have:

    • a full backup of each semester, and they are never deleted.
    • a monthly full backup of the last 12 months.
    • the backups and archive logs of the last 3 months in tape or secondary storage.
    • the backups and archive logs of the last month in disk.

    According to a schema like this, you could know when you can delete the archive files. Remember that the archive logs allows you to recover the database to any point in time.

    Having the archive logs in disk allows you to recover the database at any moment if you have a crash. And you do not restore to stage the files from secondary to primary storage.

    Remember, if you perform a full backup, and there were operations during the backup, you should need some archive logs to start the database. It is always a good idea to test the backup for history when you are going to delete the archive logs. If a database after being restored needs archive logs, and you do not have them, the backup file is useless.

    P.D. It is a good idea to have old backups, for example when you are going to incorporate a data warehouse, and you need to analyze the evolution of the data.