Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Scheduling database backups in MS SQL 2005 Express
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Scheduling database backups in MS SQL 2005 Express

 Post Reply Post Reply
Author
iSec View Drop Down
Senior Member
Senior Member
Avatar

Joined: 13 February 2005
Status: Offline
Points: 1140
Post Options Post Options   Thanks (0) Thanks(0)   Quote iSec Quote  Post ReplyReply Direct Link To This Post Topic: Scheduling database backups in MS SQL 2005 Express
    Posted: 27 October 2008 at 6:47am
This used to be an easy task when I had SQL 2000 as the SQL 2000 Agent was part of SQL 2000 database server. However after switching to SQL 2005 Express I can no longer schedule backups... primarily because of the fact that the "express" edition of MSSQL does not have it or allow it.
 
I have already googled this but still I am unsure of the quickest and proper way of scheduling backups through MSSQL Express. Does anyone here know how this can be done?
"When it gets dark enough, you can see the stars"
-Charles A. Beard
Back to Top
michael View Drop Down
Senior Member
Senior Member
Avatar

Joined: 08 April 2002
Location: United States
Status: Offline
Points: 4670
Post Options Post Options   Thanks (0) Thanks(0)   Quote michael Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2008 at 1:11am
Create a SP that does all the backups you need - schedule a Windows Job to run every day or so.
Back to Top
WebWiz-Bruce View Drop Down
Admin Group
Admin Group
Avatar
Web Wiz Developer

Joined: 03 September 2001
Location: Bournemouth
Status: Offline
Points: 9844
Post Options Post Options   Thanks (0) Thanks(0)   Quote WebWiz-Bruce Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2008 at 7:56am
I use to do SQL Server backups through the command line for this website for SQL Server 2005 Express by creating a batch file called backupSqlServer.bat.

The code was:-

REM *****************************
REM Backup SQL Server
REM *****************************

REM To restore use SQL Manager Studio - Restore form file using .bak file

md c:\Backup\Database


REM Backup Web Wiz SQL Server DB's
REM *********
osql -E -S .\ -Q "BACKUP DATABASE Web Wiz TO DISK='c:\Backup\Database\Web Wiz2.bak'"
REM SQL Server appends to previous backup making larger files, so save Web Wiz2.bak then delete and rename Web Wiz.bak
if exist c:\Backup\Database\Web Wiz2.bak goto exist
goto end
:exist
del c:\Backup\Database\Web Wiz.bak
ren c:\Backup\Database\Web Wiz2.bak Web Wiz.bak
:end


You then create a scheduled tasks in windows to run the backupSqlServer.bat file whenever you want.
Back to Top
MadDog View Drop Down
Mod Builder Group
Mod Builder Group
Avatar

Joined: 01 January 2002
Status: Offline
Points: 3008
Post Options Post Options   Thanks (0) Thanks(0)   Quote MadDog Quote  Post ReplyReply Direct Link To This Post Posted: 06 November 2008 at 6:32pm
Thank you Bruce! Just what i was looking for Thumbs Up
Back to Top
ntk View Drop Down
Newbie
Newbie


Joined: 02 March 2009
Status: Offline
Points: 1
Post Options Post Options   Thanks (0) Thanks(0)   Quote ntk Quote  Post ReplyReply Direct Link To This Post Posted: 02 March 2009 at 2:36pm
I had to do this recently. My background is network and Win sys admin with limited dba skill.
 
What I found helpful was to install SQL Server 2005 Management Studio Express.
 
Once you've installed Mgmt Studio, pick the DB in question, right-click on the DB, choose All Tasks > Backup. Pick the right options for your case, and toward the middle on top is a button that says Script. Choose Script to File. Save to file and on the Backup window choose cancel (if you hit OK it'll run a backup, which may not be what you want at that time). This process will create a FileName.sql file for you.
 
Create a .bat file which for me looks like:
@ECHO off
ECHO Attempting to backup Database
sqlcmd -S localhost -E /i FileName.sql
ECHO.
ECHO If no error message is shown, then the database was backed up correctly.
ECHO.
PAUSE
 
Note: I placed the .bat and .sql in the same directory, hence the argument to /i is not absolute path.
 
Run the .bat file, and if there are no errors modify the batch file by removing the PAUSE.
 
Create a scheduled task to run the .bat file.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.