Skip to main content

How to backup an existing SQL Server database to a location in '.BAK', then restore the '.BAK' file using different database name.

--
-- BACKUP and RESTORE an existing database to a new database
--

BACKUP DATABASE AdventureWorks2012 TO DISK = 'C:\AdventureWorks2012.BAK';
GO

RESTORE DATABASE NewAdventureWorks2012
   FROM DISK = 'C:\AdventureWorks2012.BAK'
   WITH
      MOVE 'AdventureWorks2012_Data' TO 'C:\NewAdventureWorks2012_Data.mdf',
      MOVE 'AdventureWorks2012_Log'  TO 'C:\NewAdventureWorks2012_log.ldf', REPLACE;
GO