Skip to content

Instantly share code, notes, and snippets.

@jordanfarrer
Created November 22, 2014 15:55
Show Gist options
  • Save jordanfarrer/1af1aedde4279a0eabd1 to your computer and use it in GitHub Desktop.
Save jordanfarrer/1af1aedde4279a0eabd1 to your computer and use it in GitHub Desktop.
Full Database Backup Script
DECLARE @BackupPath nvarchar(512) = '<Directory Path of Destination Folder>'
DECLARE @BackupName nvarchar(512) = '<Name of Backup File>'
DECLARE @FullBackupPath nvarchar(512) = @BackupPath + '\' + @BackupName + '.bak'
BACKUP DATABASE <Database Name>
TO DISK = @FullBackupPath
WITH FORMAT,
MEDIANAME = @BackupName,
NAME = '<Backup Name>'
-- REMEMBER: Add the SQL Server user to be able to write to the destination directory
-- SQL Server user can be found by looking at the Services -> SQL Server -> Log On properties page
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment