Not logged in - Login

Backup database in SQL

This sample t-sql script demonstrates how to backup up the database and log files.

-- Backup database files. Do NOT truncate files.
-- declare variables to hold backup information
declare @db varchar(100)
declare @backupPath varchar(255)
declare @backupPathLog varchar(255) 

-- set the variables
set @db = 'EnterDatabaseNameHere'
set @backupPath = 'SetBackupFilePathNameHere'
set @backupPathLog = 'SetLogBackupFilePathNameHere'
-- note: backup the database
print ''
print 'backup the database'
BACKUP database @db to disk=@backupPath with init

-- note: backup the log
print ''
print 'backup the log'
BACKUP LOG @db to disk=@backupPathLog with init