Automate Backups in SQL Express


  I need to automate backups for a SQL Express installation.     Some sort of  daily backup maintenance plan.    I been told that it's not as simple as setting up a job using SQL management studio in the full version.

  Please any tips, links, help , tutorial that will orient me on how to this.

joe_echavarriaDatabase AdministratorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SQL Express edition does not offer a way to automate backups. What I have done in the past while dealing with Express editions, I would create an exe (usually using .NET) or PowerShell script that would perform backup. Then I'd schedule that script or exe via Windows scheduler on the server

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Éric MoreauSenior .Net ConsultantCommented:
I am using It is a set of commands that you schedule through Windows Task Scheduler
Below are two code samples that use AdventureWorks database as an example:


$svr = New-Object 'Microsoft.SqlServer.Management.SMO.Server' $inst
$bdir = $svr.Settings.BackupDirectory
$db = $svr.Databases['AdventureWorks']
$dbname = $db.Name
$dt = get-date -format yyyyMMddHHmmss
$dbbk = new-object ('Microsoft.SqlServer.Management.Smo.Backup')
                              $dbbk.Action = 'Database'
                              $dbbk.BackupSetDescription = "Full backup of " + $dbname
                              $dbbk.BackupSetName = $dbname + " Backup"
                              $dbbk.Database = $dbname
                              $dbbk.MediaDescription = "Disk"
                              $dbbk.Devices.AddDevice($bdir + "\" + $dbname + "_db_" + $dt + ".bak", 'File')

Open in new window


Dim conn As New ServerConnection(serverName, userName, passWd) 
Dim oSQLServer As New Server(conn) 'create the SMO server object using connection
Dim OrigBackupPath As String = oSQLServer.Information.MasterDBPath.Replace("\DATA", "\Backup\AdventureWorks.BAK") ' -- set the path where backup file will be stored
Dim bkDevItem As New BackupDeviceItem(OrigBackupPath, DeviceType.File) ' -- create SMO.Backupdevice object

With oBackup ' Set the backup object property 
         .Action = BackupActionType.Database
         .Database = "AdventureWorks"
         .Initialize = True
         .Checksum = True
         .ContinueAfterError = True
         .Incremental = False
End With

Open in new window

Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

Vitor MontalvãoMSSQL Senior EngineerCommented:
I think any solution will work but my preference is too save the backup commands to a .sql file and schedule it to run in the task scheduler.
Microsoft even wrote an article on how to do that. If you're interested you have the full process and code here.
HuaMin ChenProblem resolverCommented:
You can run Stored proc to do backup, using the codes like
DECLARE @name VARCHAR(50) -- database name  
DECLARE @path VARCHAR(256) -- path for backup files  
DECLARE @fileName VARCHAR(256) -- filename for backup  
DECLARE @fileDate VARCHAR(20) -- used for file name

-- specify database backup directory
SET @path = 'C:\Backup\'  

-- specify filename format

SELECT name 
FROM master.dbo.sysdatabases 
WHERE name NOT IN ('master','model','msdb','tempdb')  -- exclude these databases

OPEN db_cursor   
FETCH NEXT FROM db_cursor INTO @name   

       SET @fileName = @path + @name + '_' + @fileDate + '.BAK'  
       BACKUP DATABASE @name TO DISK = @fileName  

       FETCH NEXT FROM db_cursor INTO @name   

CLOSE db_cursor   
DEALLOCATE db_cursor

Open in new window

and you can can have scheduled job to call such Stored proc, periodically.
HuaMin ChenProblem resolverCommented:
In SQL Management Studio, navigate to the server, then expand the SQL Server Agent item, and finally the Jobs folder to view, edit, add scheduled jobs.
Éric MoreauSenior .Net ConsultantCommented:
HuaMinChen, the asker is using Express which doesn't come with the scheduler.
joe_echavarriaDatabase AdministratorAuthor Commented:
Thanks guys for your support.

I have used an Power Shell scripts  to perform the backups.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.