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.
Applies to
- imos iX 2019 and later, with the database on Microsoft SQL Server (including Express)
- Tools:
sqlcmdand 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
- In imos iX, open Systeem → iX opties (System, iX options) and note the Server and Database.
- On the SQL server, create the folder
C:\IMOS_BACKUPfor the backups. - Create the folder
C:\IMOS_DB_backupfor the scripts. - 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
- Open Notepad and paste this line. Replace
IMOS_DEMOwith 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- Save the file as
C:\IMOS_DB_backup\imos_backup.sql.
Creating the batch file
- Open a new file in Notepad and paste these lines. Replace
SRV-SQL\IMOSSQL2019with the server from iX options andIMOS_DEMOwith 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%"- Save the file as
C:\IMOS_DB_backup\imos_backup.bat.
Testing the script
- Open Command Prompt under the account that will run the task.
- Run
C:\IMOS_DB_backup\imos_backup.bat. - Check that you see
BACKUP DATABASE successfully processedand1 file(s) copied. - 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
- Open Task Scheduler on the server.
- On the right, choose Create Task… and name the task
imos database backup. - On the General tab, choose an account that is allowed to make backups in SQL Server.
- Enable Run whether user is logged on or not.
- On the Triggers tab, choose New…, then Daily, and set a time when the server is on and nobody is drawing.
- On the Actions tab, choose New…, then Start a program.
- Under Program/script, enter
C:\IMOS_DB_backup\imos_backup.bat. - Click OK and enter the account password.
- Right-click the task and choose Run for a first test.
- Check that Last Run Result shows
0x0and that the .bak file is fresh.
A backup on the same disk is not yet a safe backup. If the server disk fails, you lose both the database and the backups. So add a copy to another location at the bottom of the batch file and give the task account write permissions there:
copy /Y "C:\IMOS_BACKUP\IMOS_DEMO.bak" "\\SRV-FILE\imos-backup\"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.
Common mistakes
- Never checking the task. Agree who checks every week that there is a fresh .bak file. A backup task can fail silently for months.
- Never testing a restore. Restore a backup into a test database now and then, so you know it is usable.
- Backing up only the database. The imos folder with drawings, templates and CNC settings is not in the database. Include it in your file backup.
- Putting a password in the batch file. Use
-E(Windows authentication) instead of-Uand-P, so no password sits readable on disk.
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
- How do I back up and restore the imos iX database?
- How do I work with a test database alongside my production database in imos iX?
- How do I move imos iX to a new server?
- Have our consultants review your backup and imos environment
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.