MS SQL backup

Share your ARGUS TV tips & tricks here
Post Reply
User avatar
andrewNZ
Posts: 677
Joined: Thu Nov 26, 2009 2:07 pm
Location: Dunedin, New Zealand

MS SQL backup

Post by andrewNZ » Thu Jan 23, 2014 8:14 am

I thought I'd post this bat file. I use it to provide an additional backup for my ARGUS TV database. I run it via the task scheduler.

The script backs up the database to a public folder, then moves it to the location I want. This is because I couldn't get it to backup directly to the location I wanted.

Code: Select all

echo off
cls
echo -- BACKUP DATABASE --
set DATABASENAME=ArgusTV

:: filename format Name-Date (eg ArgusTV-20130805.bak)
set DATESTAMP=%DATE:~-4%%DATE:~7,2%%DATE:~4,2%

:: Change backup path here
set BACKUPFILENAME=C:\Users\Public\Documents\%DATABASENAME%-%DATESTAMP%.bak
set SERVERNAME=.\sqlexpress
echo.

sqlcmd -E -S %SERVERNAME% -d master -Q "BACKUP DATABASE [%DATABASENAME%] TO DISK = N'%BACKUPFILENAME%' WITH INIT , NOUNLOAD , NAME = N'%DATABASENAME% backup', NOSKIP , STATS = 10, NOFORMAT"
echo.
echo -- moving file --
move /Y C:\Users\Public\Documents\%DATABASENAME%-%DATESTAMP%.bak "X:\ServerFolders\SQL Backup\"
You can fix it, or you can fix it until it's broken. I usually choose the latter.

Server: WHS 2011. Hauppauge HVR 2200. Avermedia A835. ArgusTV Server. EPG Collector.
Clients: Win7 64bit. MediaPortal. ArgusTV Client. StreamedMP.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests