Microsoft SQL 2005 backup / replace script

Microsoft SQL 2005 backup / replace script

USE database;

GO

BACKUP DATABASE database

TO DISK = ‘Y:\MSSQL_copy\database.Bak’

   WITH FORMAT,

      MEDIANAME = ‘databasebackup’,

      NAME = ‘Full Backup off database’;

GO

RESTORE FILELISTONLY

   FROM DISK = ‘Y:\MSSQL_copy\database.Bak’

 

RESTORE DATABASE database_copy

   FROM DISK = ‘Y:\MSSQL_copy\database.Bak’

   WITH MOVE ‘PROD2_Data’ TO ‘Y:\MSSQL databases\database_copy.mdf’,

   MOVE ‘PROD2_Log’ TO ‘X:\MSSQL Logfiles\database_copy.ldf’;

GO

Leave a Reply

Your email address will not be published. Required fields are marked *

16 − two =

This site uses Akismet to reduce spam. Learn how your comment data is processed.