Fast recovery and backup of SQL Server database

Time:2020-3-29

This paper shares two methods of SQL Server database recovery and backup for your reference. The specific contents are as follows

The first method:Usually, we use the method of restoring backup to select the target database and the source device.
The screenshot is as follows:

The second method:This way is not convenient sometimes, and the script way will be more convenient. The script way is as follows.

/*
Back up the data DB to the. Bak file. Then use this bak file to recover a new database dbtest.
*/
USE master
BACKUP DATABASE DB 
 TO DISK = 'e:\DBTest.bak'
 
RESTORE FILELISTONLY 
 FROM DISK = 'e:\DBTest.bak' 

RESTORE DATABASE DBTest 
 FROM DISK = 'e:\DBTest.bak' 
 WITH MOVE 'DBTest' TO 'E:\Program Files\Microsoft SQL Server2005\Data\DBTest.mdf', 
 MOVE 'DBTest_log' TO 'E:\Program Files\Microsoft SQL Server2005\Data\DBTest_log.ldf',
   STATS = 10, REPLACE
GO

Note:

STATS = 10 One record per 10% completed
REPLACEUsing bak to recover database and force restore
DBTestandDBTest_logIt’s the logic file in G: \ back.bak above

The above is the method of SQL Server database recovery and backup. I hope it will help you in your study.