How to backup a file while service is active?

When making a Duplicati Backup all is going fine but I get one error:

Duplicati.Library.Main.Operation.Backup.FileBlockProcessor.FileEntry-PathProcessingFailed]: Failed to process path: C:\Program Files…\data\ ]

There is a windows service active that is writing to this database. Is it possible to backup this file as well while running this service? Or do I have to close the service, make a backup and start it up again? Is there a way to automate this in Duplicati?

Yes, it is possible, and others will soon tell you here how. I want to comment on the dangers of doing so in general. Before you take a snapshot of your database while it is being updated, you have to consider whether you can make use of that snapshot, whether you can be sure the snapshot was taken in a consistent state. If the snapshot was taken at a moment that produced an inconsistent database, you might not be able to make any use of it at all. Some databases can be restored form backup, if the journal files are also included, but in some cases it might just not be possible. So you have to first find out which is the possible in this particular case.

Enabling snapshots will let you back up open files. See the –snapshot-policy option.

Note that you will have to run the Duplicati engine in an elevated state for it to be able to create snapshots. By default Duplicati runs as a user application after logon in a non-elevated state. There are at least two ways to accomplish this. Some people choose to switch Duplicati over to running as a system level service. Others choose to launch Duplicati at logon by using Task Scheduler (which provides an option to start it elevated).

@AimoE is correct though - enabling snapshots doesn’t guarantee that the file itself is internally consistent at the application level. But at least you’ll get something backed up rather than nothing.

Welcome to the forum @HJvD

In other words, you need to look at the recommendations of whatever you’re running. Some databases respect VSS, and may make good backups with Duplicati’s snapshot ability. Others don’t support VSS.

The problem is that database programs keep data in memory. Until forced to files, backups can’t get it.
Shadow Copy Creation for Providers is the complicated dance which a VSS-aware service aims to do.

Windows VSS is not guaranteed to work. Service stop or promised-reliable-while-active backup is best. This sense of the word “backup” is to take the active database and dump it into static files for a backup.

Although you obscured portions of total path, I wonder if this is an H2 database (has the .mv.db suffix)?
H2 Database Engine may fit if you use that as a Windows Service. If it’s in an app, what does app say?

If you find your DB does not support VSS, then the alternative is to have it “backup” to files in the way it considers active-safe (possibly orchestrating with scripting options), then take a file backup of its output.