sarpay
6/18/2015 - 10:57 AM

[sql] Daily Backup Plan

[sql] Daily Backup Plan

DECLARE @SqlString NVARCHAR(300)
DECLARE @TimeStamp VARCHAR(10)

SET @TimeStamp = CAST(CONVERT(date,SYSDATETIME()) AS VARCHAR(10))
SET @SqlString = N'BACKUP DATABASE [MikroDB_V15_REFLEKS] TO DISK = ''G:\BACKUP\MUHASEBE\Mikro v15\Mikro_v15_' + @TimeStamp + '.bak'' WITH NOFORMAT, NOINIT, NAME = ''MikroDB_V15_REFLEKS-Full Database Backup'', SKIP, NOREWIND, NOUNLOAD, STATS = 10'

--PRINT @SqlString
EXEC sp_executesql @SqlString
::Save this file as a batch ".bat" file.
::Create a new task using windows task scheduler to execute daily.

echo off
sqlcmd -E -S RYSERVER -i "E:\Mikro\SQLBackups\MikroDailyBackup.sql"