Backup size confusion

  • My backup sproc logs the start and finish of a database backup. It then updates my BackupSchedule table with the size of the backup in MB using the below:

    update a

    set backupSizeMB = b.backup_size / 1048576

    from DBAUtility.dbo.backupschedule as a

    inner join msdb.dbo.backupset as b

    on a.databasename = b.database_name

    where a.databasename = @DBName

    and b.backup_set_id = (select MAX(backup_set_id)

    from msdb.dbo.backupset as c

    where b.database_name = c.database_name)

    The weird thing is, for the master database, the size I logged in my table matches the size of the backup file. However, for other databases the size is out by a couple of gigs!!

    Any ideas?

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • SQL 2005 or SQL 2008?

  • No, no backup compression no...

    This particular server is 2005.

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Very strange.. so in backupset table, only the master database's size matches the size of the physical file. For my other databases, the backupset table holds a smaller size than the actual physical backup file.

    Anyone seen this before?

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Using a 3rd party compression tool? Got hyperbac installed?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • No, I'm using native SQL backup

    So the backupset table tells me this:

    On the NAS I see this:

    Notice the timestamp differences? No idea what's going on!

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Are you writing to the same file on each backup run?

  • anthony.green (11/15/2012)


    Are you writing to the same file on each backup run?

    Yes I am.

    Okay so I've done a local backup of the model database and the backup file size matches the size in the backupset table. No surprises there.

    Somethin'gs not quite right with my process.

    Basically I have created a backupschedule table like the below:

    I then use a sproc which loops through the record above like this:

    BEGIN TRY

    -- log the start time of the backup

    update QbaseDBAUtility.dbo.backupschedule

    set backupstartdate = GETDATE()

    where databasename = @DBName

    and backupdate = dateadd(dd, 0, DATEDIFF(dd, 0, getdate()))

    IF @BackupTtype = 'F'

    BEGIN

    SET @SQL = 'BACKUP DATABASE [' + @DBName + '] TO DISK = N' + CHAR(39) + @BackupFolderPath + @DBName +

    '.complete'' WITH NAME = N' + char(39) + @DBName + ' Complete Backup' + char(39) + ', BUFFERCOUNT = 1024, CHECKSUM'

    EXEC(@SQL)

    END

    ELSE IF @BackupTtype = 'D'

    BEGIN

    SET @SQL = 'BACKUP DATABASE [' + @DBName + '] TO DISK = N' + CHAR(39) + @BackupFolderPath + @DBName +

    '.Differential'' WITH DIFFERENTIAL, NAME = N' + char(39) + @DBName + ' differential backup' + char(39) + ', BUFFERCOUNT = 1024, CHECKSUM'

    EXEC (@SQL)

    END

    -- log the end time of the backup

    update QbaseDBAUtility.dbo.backupschedule

    set backupenddate = GETDATE(),

    BackupStatus = 'Success'

    where databasename = @DBName

    and backupdate = dateadd(dd, 0, DATEDIFF(dd, 0, getdate()))

    -- Let's also get the backup size

    update a

    set backupSizeMB = b.backup_size / 1048576

    from QbaseDBAUtility.dbo.backupschedule as a

    inner join msdb.dbo.backupset as b

    on a.databasename = b.database_name

    where a.databasename = @DBName

    and backupdate = dateadd(dd, 0, DATEDIFF(dd, 0, getdate()))

    and b.backup_set_id = (select MAX(backup_set_id)

    from msdb.dbo.backupset as c

    where b.database_name = c.database_name)

    END TRY

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • The problem is that your expecting to store the file size of the actual physical file into your table which is not what your getting. What your getting is the size of the logical backup which was just appeneded to the file which is correct for your procedure. If you want the file size on disk you will need to loop through your existing sizes in your schedule table and add up the total size or use a WMI query or something similar to get the size from the file system.

    One thing I would strongly recommend is to use a timestamp in your backups and write to a new file every time and not append backups to the same file as if you get corruption in the backupset the whole backupset could be rendered invalid and you cannot restore from it so you loose all recoverability.

  • Thanks Tony.

    I've done some more testing on a different server and it does appear the backup size field is the actual size of thephysical backup file:

    As to the difefrence in sizes from last night's backups.. no idea.... weirdness!

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • Hi

    It seems to me more like the backup files are getting appenend As a result the physical backupfile is bigger than the size in backupset

    Thanks and Regards

    Santhu

Viewing 11 posts - 1 through 10 (of 10 total)

You must be logged in to reply to this topic. Login to reply