I am learning about database backups in SQL server 2008.
I took a full database backup using following query:
BACKUP DATABASE TEST_DB TO DISK='D:\TEST_DB.bak'
The above query created a BAK file on D drive whose size is 2.5mb
Processed 304 pages for database 'TEST_DB', file 'TEST_DB' on file 1. Processed 2 pages for database 'TEST_DB', file 'TEST_DB_log' on file 1. BACKUP DATABASE successfully processed 306 pages in 0.039 seconds (61.110 MB/sec). I immediately ran differential backup query on the same database:
BACKUP DATABASE TEST_DB TO DISK='D:\TEST_DB.bak' WITH DIFFERENTIAL
now the BAK size increased to 2.95 mb
Processed 40 pages for database 'TEST_DB', file 'TEST_DB' on file 2. Processed 1 pages for database 'TEST_DB', file 'TEST_DB_log' on file 2. BACKUP DATABASE WITH DIFFERENTIAL successfully processed 41 pages in 0.011 seconds (29.119 MB/sec).
What I don't understand is that I did not make any changes to the database between the two backups, then how come differential backup increase the size of the BAK file?
Because you are using the same file name and are not including the WITH INIT option. So it appended the full backup AND the differential into one file. Use a different file name, and I recommend never appending files (meaning always use WITH INIT option).
Well what file sizes did you get this time? And please use a different file name for each command so that you aren't overwriting the file each time you run the command.
There is going to be some overhead data in each file so the differential is never going to be 0 in size even if you didn't make any changes. Your database is so small that we might be near the overhead size.