Skip to content

Instantly share code, notes, and snippets.

@ruslander
Created April 18, 2011 13:47
Show Gist options
  • Save ruslander/925367 to your computer and use it in GitHub Desktop.
Save ruslander/925367 to your computer and use it in GitHub Desktop.
MS Sql Backup, Restore script
=========== BACKUP
USE master;
BACKUP DATABASE [Ecp]
TO DISK = N'C:\dbbackups\ecp.Bak' WITH NOFORMAT, NOINIT,
NAME = N'Ecp-Full Database Backup', SKIP, NOREWIND, NOUNLOAD, STATS = 10
=========== RESTORE
USE master;
ALTER DATABASE [Ecp] SET OFFLINE WITH
ROLLBACK IMMEDIATE
GO
RESTORE DATABASE [Ecp]
FILE = N'Ecp' FROM DISK = N'C:\dbbackups\ecp.Bak' WITH FILE = 1,
NOUNLOAD, REPLACE, STATS = 10
GO
ALTER DATABASE [Ecp] SET ONLINE
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment