Create Backup File with Password protection
TSQL to backup database with password
Backup Database TEST To Disk ='C:\Temp\TEST.BAK' With MediaPassword='DBPassword'
GO
Now we cannot restore this database or get details of database from this backup without knowing the password.
We will get the below error:
Msg 3279, Level 16, State 6, Line 1
Access is denied due to a password failure
Msg 3013, Level 16, State 1, Line 1
RESTORE HEADERONLY is terminating abnormally.
Now to restore the database run below command:
Restore Database TEST From Disk='C:\Temp\TEST.BAK' With MEDIAPASSWORD='DBPassword'
To resore details of the backup run below command
Restore HeaderOnly From Disk='C:\Temp\TEST.BAK' With MEDIAPASSWORD='DBPassword'
No comments:
Post a Comment