• GSquared (9/26/2012)


    For example, I've set up scripts that would check the current LSNs vs the last ones backed up, and customize which databases to back up based on that.

    Hi,

    Could you shed a light on how to compare current LSN with the LSN of last backup?

    I have one instance hosting around 150 databases. Daily all the backups need to be copied to DR site and restored.

    Most of database are not very active. I am thinking if the database is not changed, then I only need do a local backup and don't need to copy backup to DR site.

    I tried to compare Current LSN with the LSN of last backup, but no luck.

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

    For example, for Database TestLSN

    to get current LSN

    select * from fn_dblog(null,null)

    the result:

    000000e2:000000f1:0022LOP_BEGIN_CKPT

    000000e2:000000ff:0001LOP_END_CKPT

    To get Backup LSN

    select backup_start_date,first_lsn,last_lsn

    from msdb..backupset where database_name='testlsn'

    and backup_start_date>'2012/09/28'

    order by backup_set_ID

    The result:

    2012-09-28 09:43:45.000226000000019400040226000000021100001

    2012-09-28 14:15:55.000226000000021900037226000000023500001

    select

    convert(bigint, 0x000000e2) * 1000000000000000 +

    convert(bigint, 0x000000f1) * 100000 +

    convert(int, 0x0022)

    The result: 226000000024100034

    select

    convert(bigint, 0x000000e2) * 1000000000000000 +

    convert(bigint, 0x000000ff) * 100000 +

    convert(int, 0x0001)

    The result: 226000000025500001

    They are not equal.

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

    What did I miss?

    Thank you very much.