Comments
3 comments
-
Could you please post the T-SQL command that's ran by the job step that performs the restore on the standby server? Thanks.
-
Hi Peter
Unfortunately, I don't have the original seed restore command. We are in the middle of a server migration and already running behind schedule so I can't go through the process again.
The problem (I think) is in the way the shipped backups are moved to the processed folder. I'm assuming this is performed using an OS "copy" command rather than a "move".
This is the log shipping restore command if that helps.
DECLARE @errorCode INT
DECLARE @sqlerrorCode INT
EXECUTE master..sqlbackup N'-SQL "RESTORE LOG [UKREPDIWPRD] FROM DISK = ''\\UKBHSR195\LOG_SHIPPING\UKREPDIWPRD\LOG_UKREPDIWPRD_*.sqb'' WITH ERASEFILES = 48h, NORECOVERY, MOVETO = ''G:\LOG_SHIPPING\UKREPDIWPRD\PROCESSED''"', @errorCode OUT, @sqlerrorCode OUT;
IF (@errorCode >= 500) OR (@sqlerrorCode <> 0)
BEGIN
RAISERROR ('SQL Backup failed with exit code: %d SQL error code: %d', 16, 1, @errorCode, @sqlerrorcode)
END -
The log shipping command was what I wanted.
If "\\UKBHSR195\LOG_SHIPPING\UKREPDIWPRD" maps to ''G:\LOG_SHIPPING\UKREPDIWPRD" on the standby server, then change "\UKBHSR195\LOG_SHIPPING\UKREPDIWPRD" to ''G:\LOG_SHIPPING\UKREPDIWPRD" as the source of the files e.g.
EXECUTE master..sqlbackup N'-SQL "RESTORE LOG [UKREPDIWPRD] FROM DISK = ''G:\LOG_SHIPPING\UKREPDIWPRD\LOG_UKREPDIWPRD_*.sqb'' WITH ERASEFILES = 48h, NORECOVERY, MOVETO = ''G:\LOG_SHIPPING\UKREPDIWPRD\PROCESSED''"', @errorCode OUT, @sqlerrorCode OUT;
This should trigger the expected 'move' behaviour.
Add comment
Please sign in to leave a comment.
Is it possible to make the final part of the process into a true "move" rather than a copy? Some of our logs can be large (e.g. 5GB) which can take several minutes to copy. As the processed folder is on the same drive as the share folder, the file could actually just be "moved" which would take virtually no time at all. (enhancement request?)
Thanks
Vince