How to schedule SQL Server Express backups
SQL Server Express does not include SQL Server Agent, so there is no built-in way to run a backup every night. Microsoft documents a manual method that uses a stored procedure, the sqlcmd tool and Windows Task Scheduler. This guide walks through it and adds a checklist for proving the backups are good.
Why Express needs a workaround
SQL Server Agent is the component that runs scheduled jobs and maintenance plans. Microsoft's documentation states that it is not included in SQL Server Express, so you cannot schedule backup jobs or maintenance plans the way you can in other editions.
You can still back up an Express database on demand with sqlcmd, SQL Server Management Studio (SSMS), the MSSQL extension for Visual Studio Code, or a Transact-SQL script that uses the BACKUP commands. To make those run on a schedule, Microsoft's article uses Windows Task Scheduler as the scheduler.
Before you start, you need the following.
- A running SQL Server Express instance (Microsoft's examples use the default named instance, .\SQLEXPRESS)
- Membership in the sysadmin server role, which is needed to create the stored procedure in the master database
- A local folder or drive with enough free space for the backup files
- Permission to create scheduled tasks on the computer that runs Express
The four steps Microsoft describes
Microsoft's article sets up scheduled full, differential and transaction log backups in four steps. Use the article for the exact script and batch file text, because the details matter.
- Step 1: create the sp_BackupDatabases stored procedure in the master database, using Microsoft's downloadable script. It takes the backup folder, the backup type (F for full, D for differential, L for log) and an optional database name.
- Step 2: make sure the sqlcmd utility is installed and reachable. It comes with SSMS and is also a standalone download.
- Step 3: create a small batch file that calls sqlcmd and runs the procedure. Microsoft gives examples for full, differential and log backups. Keep the -b option in the sqlcmd call: without it, sqlcmd reports success even when the backup fails, and Task Scheduler shows the task as successful.
- Step 4: in Task Scheduler, create a basic task that runs the batch file on a schedule, and check on the General tab that the account it runs under can run sqlcmd and has permission to back up the databases.
Check that the backups actually ran
Microsoft is blunt about this: a task that Task Scheduler reports as successful is not proof that a backup succeeded. After the first scheduled run, check three things.
- New .bak files (full and differential) or .trn files (log) appear in the backup folder with a date and time stamp in the name
- In Task Scheduler, the Last Run Result column for your task. With the -b option, a value of 0x1 means the backup command failed
- The backup history in the msdb database. Microsoft's article includes a query for it.
Know the limits of this method
Microsoft lists the limits of the manual approach itself. It has no built-in job history, retry logic or failure alerts. The stored procedure does not delete old backup files, so the drive can fill up. It backs up only databases that are online, and silently skips ones that are offline or restoring. The Task Scheduler service must be running when the task is due.
That means someone has to look. A weekly review is a reasonable habit: confirm a recent file exists for every database, confirm the Last Run Result, and confirm free space.
A practical way to cover the gaps is a one-page runbook: which databases are backed up, how often, where the files go, who reviews the folder and how often, and who can run a restore. A common pattern, which Microsoft's article supports by giving examples for each type, is a full backup on a longer cycle with differential and log backups between. Log backups need the full or bulk-logged recovery model and at least one earlier full backup, so check the recovery model of each database before you rely on them.
A backup you have not restored is a guess
Practice a restore on a different machine or under a different database name, so you never risk the live database. In SSMS, right-click Databases, choose Restore Database, pick the backup under Device, and give the database a new name in the Destination section. Microsoft's restore article walks through this, including restoring to a point in time.
Also keep a copy of the backup folder somewhere other than the server itself. A backup on the same disk as the database does not survive the disk. Write down where the copy goes and who checks it.
Where ExpressGuard fits
ExpressGuard is coming soon. It is planned to automate this routine on Express: the schedule, copies to another location, test restores and an alert when a backup fails or is missed. Until it is released, the manual method above works, as long as someone checks it.
Sources
- Microsoft Learn: Schedule and automate backups of SQL Server Express databases
- Microsoft Learn: Restore a database backup using SSMS
Coming soon: ExpressGuard
Scheduled SQL Server Express backups, copied off-site and tested. ExpressGuard makes scheduled backups of small SQL Server databases, copies them off-site, test-restores them and alerts you if anything fails. It is for small businesses whose business software quietly installed the free Express edition that nobody backs up, and for the IT consultants who look after those servers.
Get ExpressGuard first
Join the list and get 25% off your first purchase when it goes on sale. We email you a discount code on launch day. One code per person, for new customers.
One email when it launches (plus the discount code). No other mail, and you can say stop at any time. See our privacy policy.