Add bak-restoration script

master
prathabanKavin 10 months ago
parent c389d60750
commit ca00b087bb

@ -0,0 +1,43 @@
/*
=====Before runnning the script=====
Data File (.mdf): Contains the actual data and database objects.
Log File (.ldf): Records transactions and modifications for recovery purposes.
Backup File (.bak): A backup file containing a copy of the data and log files.
1. Specify correct .bak file path
2. Specify the new locations for .mdf, .ldf files using the WITH MOVE clause.
*/
/*
In case of below error -->
"Cannot open backup device '/home/kavin/dbdump/'. Operating system error 5(Access is denied.)."
Grant permissions to directory : chmod o+w /home/kavin/dbdump/
*/
/*
In case of below error -->
"The sp_configure value 'contained database authentication' must be set to 1 in order to restore a contained database.
You may need to use RECONFIGURE to set the value_in_use."
comment out section: Enable contained database authentication and re-run the script again
*/
/*
-- Enable contained database authentication
sp_configure 'contained database authentication', 1;
GO
RECONFIGURE;
GO
*/
-- Restore the database with the MOVE clause
RESTORE DATABASE bst_mdmum_reg
FROM DISK = '/home/kavin/bst_mdmum_reg_Full_20231129193000.BAK'
WITH
MOVE 'bst_mdmum_reg' TO '/home/kavin/dbdump/bst_mdmum_reg.mdf',
MOVE 'bst_mdmum_reg_log' TO '/home/kavin/dbdump/bst_mdmum_reg_log.ldf',
NOUNLOAD,
STATS = 5;
GO
Loading…
Cancel
Save