forked from mtikoian/SQLDBA-SSMS-Solution
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathBackup-Restore.sql
27 lines (20 loc) · 1.13 KB
/
Backup-Restore.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
BACKUP DATABASE [contsoSQLInventory]
TO DISK = N'G:\MSSQLData\SQL2016_Backup\contsoSQLInventory\FULL\contsoSQLInventory_FULL_20190206_225446.bak'
WITH NO_CHECKSUM, COMPRESSION;
RESTORE DATABASE [contsoSQLInventory_Ajay] FROM DISK = N'G:\MSSQLData\SQL2016_Backup\contsoSQLInventory\FULL\contsoSQLInventory_FULL_20190206_225446.bak'
WITH RECOVERY
,STATS = 3
,MOVE N'contsoSQLInventory' TO N'F:\MSSQLData\SQL2016_Data\contsoSQLInventory_Ajay.mdf'
,MOVE N'contsoSQLInventory_log' TO N'F:\MSSQLData\SQL2016_Log\contsoSQLInventory_Ajay_log.ldf'
GO
RESTORE DATABASE [contsoSQLInventory_Dev] FROM DISK = 'G:\MSSQLData\SQL2016_Backup\contsoSQLInventory_Distributor\FULL\contsoSQLInventory_Distributor_FULL_20190214_034700.bak'
WITH RECOVERY
,STATS = 3
,REPLACE
,MOVE N'contsoSQLInventory' TO N'F:\MSSQLData\SQL2016_Data\contsoSQLInventory_Dev.mdf'
,MOVE N'contsoSQLInventory_log' TO N'F:\MSSQLData\SQL2016_Data\contsoSQLInventory_Dev_log.ldf'
GO
select top 1 cl.DatabaseName, cl.Command, cl.StartTime
from DBA.dbo.CommandLog as cl
where cl.CommandType = 'BACKUP_DATABASE'
order by cl.StartTime desc