Skip to content

Restore backup over existing database but keep permissons #8527

Discussion options

You must be logged in to vote

Hi @tomaustin700,

A database backup on SQL Server contains all permissions too. That means when you overwrite an existing database you will also overwrite the existing permissions with the ones that your backup brings.

Therefore that's nothing Restore-DbaDatabase can help with.

However, as you mentioned, on way to accomplish this process will be:
1- Script existing permissions (Export-DbaUser)
2- Restore the database (Restore-DbaDatabase)
3- Apply permissions exported on step 1 (Invoke-DbaQuery)

To give some guidance, take a look at this blog post Replicate permissions to new Login/User with dbatools and all the other ones linked there (like the one that @SQLDBAWithABeard wrote).

Let us k…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@tomaustin700
Comment options

Answer selected by SQLDBAWithABeard
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants