Skip to content
Knowledge base

How do I schedule a daily automatic backup of imos iX?

With a small script, sqlcmd and Windows Task Scheduler you back up the imos iX database every night, even on SQL Server Express.

Short answer: Have Windows Task Scheduler start a batch file every night that uses sqlcmd to back up the imos iX database and copies the .bak file to a dated folder. This also works on the free SQL Server Express, which has no SQL Server Agent. In Wood Intelligence implementations we use this simple script because an IT administrator can review it in a few minutes.

Information

Applies to

  • imos iX 2019 and later, with the database on Microsoft SQL Server (including Express)
  • Tools: sqlcmd and Windows Task Scheduler on the SQL server
  • No Ardis, ERP or CNC integration needed: this only concerns the database
  • Last reviewed: November 2026. The script was tested with sqlcmd on an IMOSSQL2019 instance.

Preparation

  1. In imos iX, open Systeem → iX opties (System, iX options) and note the Server and Database.
iX options shows the server and database name.
  1. On the SQL server, create the folder C:\IMOS_BACKUP for the backups.
  2. Create the folder C:\IMOS_DB_backup for the scripts.
  3. Open Command Prompt on the server and type sqlcmd -?. If you get 'sqlcmd' is not recognized as an internal or external command, install sqlcmd from the Microsoft website first.

Creating the SQL script

  1. Open Notepad and paste this line. Replace IMOS_DEMO with your database name.
BACKUP DATABASE [IMOS_DEMO] TO DISK = N'C:\IMOS_BACKUP\IMOS_DEMO.bak' WITH INIT, NOUNLOAD, NAME = N'IMOS_DEMO', NOSKIP, STATS = 5, NOFORMAT
  1. Save the file as C:\IMOS_DB_backup\imos_backup.sql.

Creating the batch file

  1. Open a new file in Notepad and paste these lines. Replace SRV-SQL\IMOSSQL2019 with the server from iX options and IMOS_DEMO with your database name.
@echo off
sqlcmd -S SRV-SQL\IMOSSQL2019 -E -b -i "C:\IMOS_DB_backup\imos_backup.sql"
if errorlevel 1 exit /b 1
for /f %%i in ('powershell -NoProfile -Command "Get-Date -Format yyyy-MM-dd"') do set STAMP=%%i
md "C:\IMOS_BACKUP\%STAMP%"
copy /Y "C:\IMOS_BACKUP\IMOS_DEMO.bak" "C:\IMOS_BACKUP\%STAMP%"
  1. Save the file as C:\IMOS_DB_backup\imos_backup.bat.

Testing the script

  1. Open Command Prompt under the account that will run the task.
  2. Run C:\IMOS_DB_backup\imos_backup.bat.
  3. Check that you see BACKUP DATABASE successfully processed and 1 file(s) copied.
  4. Check that the folder with today's date contains the .bak file, for example C:\IMOS_BACKUP\2026-11-02.

If you run the script twice on the same day, md reports that the folder already exists. That is harmless: the copy is simply overwritten.

Scheduling the task in Task Scheduler

  1. Open Task Scheduler on the server.
  2. On the right, choose Create Task… and name the task imos database backup.
  3. On the General tab, choose an account that is allowed to make backups in SQL Server.
  4. Enable Run whether user is logged on or not.
  5. On the Triggers tab, choose New…, then Daily, and set a time when the server is on and nobody is drawing.
  6. On the Actions tab, choose New…, then Start a program.
  7. Under Program/script, enter C:\IMOS_DB_backup\imos_backup.bat.
  8. Click OK and enter the account password.
  9. Right-click the task and choose Run for a first test.
  10. Check that Last Run Result shows 0x0 and that the .bak file is fresh.

Cleaning up old backups automatically

This is optional. Without cleanup, the disk slowly fills up. This line removes folders in C:\IMOS_BACKUP older than 30 days. Put it at the bottom of the batch file and adjust the number of days to your own policy.

forfiles /p "C:\IMOS_BACKUP" /d -30 /c "cmd /c if @isdir==TRUE rmdir /s /q @path"

Check the path carefully: the line removes every subfolder older than the given number of days. So use a dedicated folder for the backups, containing nothing else.

Why this approach?

SQL Server Agent is the standard way to schedule backups, but it is missing from the free Express edition. Task Scheduler is on every Windows server, so this always works.

With WITH INIT, the script overwrites the same .bak file every time and then copies it to a dated folder. You always know where the latest backup is, and you can still restore an older day.

The -b option looks like a detail, but it is essential. Without -b, sqlcmd returns exit code 0 even when the backup fails. The script then copies the old .bak file to today's folder and everything appears fine. We tested this ourselves. With -b and if errorlevel 1 exit /b 1, the script stops immediately and the error shows up in Task Scheduler.

The date comes from PowerShell because date /t returns something different per language setting. On a Dutch Windows, for example, the commonly used for /f "tokens=1,2,3 delims=/. " produces the folder name 02-11-2026ma. yyyy-MM-dd is the same everywhere and sorts neatly by date.

Frequently asked questions

What does "Cannot open backup device" with "Operating system error 3" or "error 5" mean?

The full message ends with BACKUP DATABASE is terminating abnormally. With error 3 (path not found), the folder does not exist as seen from the SQL server. With error 5 (access denied), the SQL Server service account may not write to the folder. Note: the backup itself is written by the SQL Server service, not by the task account. Give that service write permissions on the folder.

The task reports "Login failed for user". What now?

The task account has no access to SQL Server. In Management Studio, under Security → Logins, create a login for this Windows account and give it the db_backupoperator role in the imos database, or choose another account.

I get "The certificate chain was issued by an authority that is not trusted". How do I fix it?

Newer versions of sqlcmd encrypt the connection by default. Add -C to the sqlcmd command to trust your own server's certificate.

Can the backup run while people are drawing?

Yes, SQL Server can make a backup while the database is in use. Anything designers save afterwards just won't be in this backup. So schedule the task outside working hours.

How do I check that a .bak file is OK?

In Management Studio, run RESTORE VERIFYONLY FROM DISK = N'C:\IMOS_BACKUP\IMOS_DEMO.bak'. For a readable file you will see The backup set on file 1 is valid. Real certainty only comes from restoring the backup into a test database.

Further reading

More than one solution

Almost every question in this knowledge base has more than one solution. The best fit depends on your workflow, machinery and integrations. Not sure which applies to you, or are you using software we don't (yet) support? Feel free to email Wood Intelligence. We're happy to think along with any challenge.

imos is a trademark of imos AG. Wood Intelligence is an independent consultancy.

Download access

Sign in to check whether this download is available.