Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No logs are restored when no diff backup has been taken yet #1998

Closed
fvanderhaegen opened this Issue Mar 19, 2019 · 5 comments

Comments

Projects
None yet
2 participants
@fvanderhaegen
Copy link
Contributor

fvanderhaegen commented Mar 19, 2019

When using sp_databaserestore to restore full, diff and log backups no logs are restored when no diff backup has been taken yet.

Sample:

exec [master].[dbo].[sp_DatabaseRestore] 
	@database='test', 
	@backuppathFull=N'[pathfull]', 
	@backuppathdiff=N'[pathdiff]', 
	@backuppathlog=N'[pathlog]',
	@restorediff=1,
	@continuelogs=0,
	@runrecovery=0,

If no DIFF backup has been taken yet and above script is executed, no logs will be applied.
This happens because @DiffLastLSN has not been set.

I solved the issue by adding following code at the of the IF-clause that checks if @BackupPathDiff is not empty:
if @DiffLastLSN is null set @DiffLastLsn=@FullLastLSN

@BrentOzar

This comment has been minimized.

Copy link
Member

BrentOzar commented Mar 19, 2019

OK, cool, did you want to check in the code for it so you can get credit? (Not sure by this issue if you meant you were going to check in the fix or not.) Thanks!

@fvanderhaegen

This comment has been minimized.

Copy link
Contributor Author

fvanderhaegen commented Mar 19, 2019

I'm rather a newbie in working with github, so I made the changes in my clone of the dev-branch but I'm unable to push my changes to origin.
This is the error message "remote: Permission to BrentOzarULTD/SQL-Server-First-Responder-Kit.git denied to fvanderhaegen."
Am I doing this the wrong way?

@BrentOzar

This comment has been minimized.

Copy link
Member

BrentOzar commented Mar 19, 2019

fvanderhaegen added a commit to fvanderhaegen/SQL-Server-First-Responder-Kit that referenced this issue Mar 19, 2019

BrentOzarULTD#1998 sp_DatabaseRestore
Set @DiffLastLSN in case no DIFF backup files are found, otherwise the logs won't get restored
@fvanderhaegen

This comment has been minimized.

Copy link
Contributor Author

fvanderhaegen commented Mar 19, 2019

The pull request has been opened

BrentOzar added a commit that referenced this issue Mar 20, 2019

#1998 sp_DatabaseRestore (#1999)
Set @DiffLastLSN in case no DIFF backup files are found, otherwise the logs won't get restored

@BrentOzar BrentOzar added this to the 2019-03 milestone Mar 20, 2019

@BrentOzar

This comment has been minimized.

Copy link
Member

BrentOzar commented Mar 20, 2019

Good job! Thanks for that. Merged it in for the March release, and I'll credit you in the release notes. Thanks!

@BrentOzar BrentOzar closed this Mar 20, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.