How to exclude open files / temporary files from backup

Hello,

During my backups I keep getting warnings like:

File locked: ~$Filename.xlsx
The process cannot access the file because it is being used by another process

I would like to exclude open Excel files / temporary ~$ files from the backup

I tried with Excluding MS Office temporary files? but unfortunately had no success.

“2026-01-26 09:06:46 +01 - [Warning-Duplicati.Library.Main.Operation.Backup.FileBlockProcessor.FileEntry-FileLocked]: Excluding path due to file locked: D:\DOKUMENTI\DJELATNIC\DJELATNICI_evidencije\POJEDINAČNE EVIDENCIJE O RADNICIMA\~$Jon Doe.xlsx\r\nIOException: The process cannot access the file ‘\\?\D:\DOKUMENTI\DJELATNICI\DJELATNICI_evidencije\POJEDINAČNE EVIDENCIJE O RADNICIMA\~$Jon Doe.xlsx’ because it is being used by another process.”
“2026-01-26 09:07:18 +01 - [Warning-Duplicati.Library.Main.Backend.BackendManager-BackendManagerShutdown]: Backend manager queue runner did not stop”

Handling locked files would be another method, unless you insist on excludes.
Backing up wastes a little backup space. Using an exclude risks over-exclude.

There were a lot of suspect answers there. The forum can also eat backslashes. Enclose strings between two backticks, or three backticks above and below line.

I made a folder of files like below to show the result of rough versus more precise filters:

C:\backup source\office>tree /f /a .
...
C:\BACKUP SOURCE\OFFICE
|   Jon Doe.xlsx
|   prefix~$Jon Doe.xlsx
|   ~$Jon Doe.xlsx
|
+---prefix~$folder
|       file.txt
|
\---~$folder
        file.txt

For a first cut, wildcard characters such as * to be used with globbing are easier to write:

*~$* excludes the real temporary file, but excludes files and folders with ~$ in the middle.
*\~$* is a little better on excess excludes, because now the ~$ has to be at start of names.

Going to a regex allows one to never exclude based on folder (where path must end with a \).
Dot is almost any character, * means repeat what's on left, [^\\] means non-backslash chars.
Special characters such as dollar and backslash get escaped by a backslash in front of them.

[.*\\~\$[^\\]*] looks for filename (not folder) that begins with tilde dollar. Is that good?
It's identical to one of the later entries in the topic, except I just use a tilde not \x7E.

Documentation:

Filters in Duplicati

Service and WindowsService
Running the Server as a Windows Service