Automating the Backup of a SQL Server 2008 Express Database

Steps Involved:

1) Create a Database Backup Script.

2) Create a Scheduled Task To Run the Backup Script.

1 Create a Database Backup Script.

a) Download and install SQL Server Management Studio. This is a free tool available on the Microsoft website.

b) Once Management Studio is installed launch it and connect to the SQL server instance that contains the database that you want to back up.

c) Right click on the database and then in the menu choose Tasks -> Back up...

d) This will open up a window where you can choose your backup options, once you are happy with the options click on the "Script" button near the top and select the "Script Action to File" option.

e) Save the File.

2 Create a Schedule Task to Run the Backup Script

a) Open up Windows Task Scheduler.

b) Create a new Task using the wizard, when asked to select a program browse to C:\Program Files\Microsoft SQL Server\100\Tools\binn\SQLCMD.exe

c) There are 2 arguments that need to be set: -S \SERVER_INSTANCE_NAME  -i "PATH_OF_SQLBACKUP_SCRIPT"
where SERVER_INSTANCE_NAME  is the name of the instance of SQL server that contains your database e.g. (local) and PATH_OF_SQLBACKUP_SCRIPT is the path of your backup script e.g. "C:\Program Files\Microsoft SQL Server\DatastoreBackup.sql"

d) Adjust the task to run at the desired times and you are done.

This article is part of the GWB Archives. Original Author: JaydPage

New on Geeks with Blogs

  • We Won The One Award I Actually Care About

    Full Scale made the Inc. 5000 for the fifth year straight, the 12th listing across my three companies. Here is why the one award you cannot buy is worth stopping for.

  • Your Customers Build the Features Now

    I let a tool I liked sit dead for a year rather than build the features I wanted. An MCP server meant I never had to, and your customers can do the same to your product.

  • Get the Size of a Directory in Linux the Easy Way

    du -sh for the quick answer, ncdu for the cleanup, df for the disk itself: every command for checking directory size in Linux, plus why du and df never agree.

  • Vim Search and Replace: The Ultimate Guide

    One :%s command replaces every match in a file before a find dialog would even open. The Vim substitute patterns worth the muscle memory: flags, ranges, capture groups, and multi-file edits.