Log shipping backups

Chaitanya Kiran 841 Reputation points
2026-09-19T06:14:16.33+00:00

Good Morning

Can we take full backup of primary database and full backup of secondary database in Log Shipping?

SQL Server Database Engine
0 comments No comments

1 answer

Sort by: Oldest
  1. Erland Sommarskog 137.5K Reputation points MVP Volunteer Moderator
    2026-09-19T19:49:03.0733333+00:00

    Let's try it!

    First preparation on server 1:

    CREATE DATABASE KiranTest
    go
    ALTER DATABASE KiranTest SET RECOVERY FULL
    go
    USE KiranTest
    go
    SELECT * INTO Objects FROM sys.objects
    go
    BACKUP DATABASE KiranTest TO DISK = 'C:\temp\KiranTest' WITH INIT, COMPRESSION
    go
    
    
    

    Copy the back to the secondary. Recall that for log-shipping, database must be in STANDBY:

    RESTORE DATABASE KiranTest FROM DISK = 'C:\temp\KiranTest'
    WITH STANDBY = 'C:\temp\KiranTest.stb',
         MOVE 'KiranTest' TO 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Data\KiranTest.mdf',
         MOVE 'KiranTest_log' TO 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\Data\KiranTest.ldf'
    go
    -- Verify that we can access the table.
    SELECT * FROM KiranTest.dbo.Objects
    go
    -- And now: Will it work?
    BACKUP DATABASE KiranTest TO DISK = 'C:\temp\KiranTest2'
    
    

    Last chance to place your bets!

    .

    .

    .

    .

    .

    Here it comes:

    Msg 3036, Level 16, State 4, Line 8 The database "KiranTest" is in warm-standby state (set by executing RESTORE WITH STANDBY) and cannot be backed up until the entire restore sequence is completed. Msg 3013, Level 16, State 1, Line 8 Actually, I'm a little surprised. I kind of expected it to work, since you can take a backup of the secondary in an Availability Group.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.