After realizing that our log files were becoming very large I pulled out our Sybase manuals and tried to determine the best way to reduce their file size. Page 459 of the SQL Studio - Adaptive Server Anywhere Administration Guide explains how to “Backup a database using the dbbackup command-line utility”. In this section of the manual I noticed that the -x switch can be used to delete and restart the transaction log, so I changed our backup command to:
cd C:\PROGRA~1\Servoy\sybase~1\win32\
C:\PROGRA~1\Servoy\sybase~1\win32\dbbackup.exe -y -c "uid=dba;pwd=sql;dbn=contacts" -x C:\Backups\01
copy "C:\PROGRA~1\Servoy\servoy.properties" C:\Backups\01
(to keep things simple I am just showing the backup command for one database named ‘contacts’)
The above example backs up database files named contacts.db and contacts.log to the c:\backups\01 folder, deletes the original contacts.log file in the database folder and restarts a new log file.
To make the above work, I placed a win32 folder inside our sybase_db folder. The win32 folder contains the following files:
dbbackup.exe (100 KB)
dblgen9.dll (572 KB)
dblib9.dll (440 KB)
dbsvc.exe (112 KB)
dbtool9.dll (1,052 KB)
Everything seems like it is working perfectly, however, when I compare file sizes of the backed up files in the Backups folder for the last four days they are as follows:
12/09/06 contacts.db 10,834 KB
12/09/06 contacts.log 22 KB
12/10/06 contacts.db 10,834 KB
12/10/06 contacts.log 24 KB
12/11/06 contacts.db 11,098 KB
12/11/06 contacts.log 106 KB
12/12/06 contacts.db 11,098 KB
12/12/06 contacts.log 66 KB
The 9th and 10th were over the weekend, so I can understand why there was little change during that period, however, why would the log file be smaller for December 12th without making the contacts.db file bigger? During that time more data was entered than was deleted.
When exactly is data moved over from the log file to the db file? Is there some kind of optimization that takes place that would explain the described changes in file size? Could it just be an inaccurate reading by the operating system? We are using Windows Server 2003.
The manual talks about log files being important because they keep track of checkpoints, so that data can be restored back to a particular point in time. If someone can explain a little more about the actual mechanics of when and how the log and db files interact it would be greatly appreciated. I have not been able to locate this information in the manuals.
Dean