Friday, March 13, 2015

restore sql server .bak and .trn series full backup and transaction log files restore process

script to restore .bak file and following transaction log files taken after this full backup script


Use Master

--Alter Database HBDB
--SET SINGLE_USER With ROLLBACK IMMEDIATE
RESTORE DATABASE HBDB FROM DISK = 'C:\last backup\HBDB_backup_2015_03_13_142615_7466371.bak' WITH NORECOVERY

RESTORE LOG HBDB FROM DISK = 'C:\last backup\HBDB_backup_2015_03_13_143001_3743946.trn' WITH NORECOVERY
GO
RESTORE LOG HBDB FROM DISK = 'C:\last backup\HBDB_backup_2015_03_13_143301_4693971.trn'
GO



ANOTHER EXAMPLE

Use Master

RESTORE DATABASE archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_20_220000_9391391.bak' WITH REPLACE , NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_20_222001_5446562.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_20_224001_1110761.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_20_230001_6931427.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_20_232001_3078836.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_20_234001_9216614.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_000001_5006193.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_002001_0712952.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_004001_6475144.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_010001_2411629.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_012001_8776987.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_014001_4470268.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_020001_0546277.trn' WITH NORECOVERY
RESTORE LOG archive_Test FROM DISK = 'E:\Production DBs Backups\HOSPITAL_DB\HOSPITAL_DB_backup_2015_03_21_022001_6839213.trn'



No comments:

Post a Comment