Duplicati Commandline Backup shouldn't fail silently

A few year ago, I setup Duplicati to Backup on PC startup (Windows) by letting the Windows Scheduler launch a .bat file.

Today I learned that for half a year, the backup process failed. When launching the .bat from command line, I do get an error message, but since it was launched in the background (or however the Windows Scheduler starts files), I never realized.

Since the moment you realize that it went wrong is for usual when you need to restore a file, I think it’s vital that the error message is somehow elevated, e.g. to a Windows Notification.

It might be that Duplicati does this already, so following are the .bat I used and the stack trace.


The .bat was, iirc, created using the GUI. Its contents are:

chcp 65001
“…\Duplicati.CommandLine.exe” backup "onedrivev2://… " “C:\#Files.…” "C:\#Files.… " “–backup-name=Main_B” "–dbpath=C:\Users.… " --encryption-module=aes --compression-module=zip --dblock-size=50mb “—passphrase=…” --exclude-files-attributes=“hidden,system,temporary” --disable-module=console-password-input “–exclude=.git\" "–exclude=.tmp” “–exclude=.xml~" "–exclude=\desktop.ini” “–exclude=.partial" "–exclude=.part” “–exclude=*.trashes”


For completeness, here is top of the error message (Apparently the Token for Onedrive had expired):
Fatal error => Autorisation mit dem OAuth Service ist fehlgeschlagen: Server error. Wenn das Problem weiter besteht, versuche ein neues AuthID Token zu generieren von: Duplicati OAuth Handler

ErrorID: OAuthLoginError
Autorisation mit dem OAuth Service ist fehlgeschlagen: Server error. Wenn das Problem weiter besteht, versuche ein neues AuthID Token zu generieren von: Duplicati OAuth Handler

Unbehandelte Ausnahme: System.AggregateException: Mindestens ein Fehler ist aufgetreten. —> System.IO.IOException: Die Pipe wurde beendet.

Hello

I don’t think that just running a command line tool should somehow grow a hand and nudge you at your keyboard when something goes wrong.
If you are doing something yourself in a batch, you can manage the return code like for any old command. Duplicati reports the following return/exit codes:
0 - Success
1 - Successful operation, but no files were changed
2 - Successful operation, but with warning(s)
3 - For backup: finished with error(s), for test: error(s) found on the backend
50 - Backup uploaded some files, but did not finish
100 - An error occurred
200 - Invalid commandline arguments found:

that you can test and use to take action.

You can also just send a mail for a backup

You can also use duplicati-monitoring.com or healthchecks.io. Search the forum for details. There are many options.

1 Like

It’s however something that is easily missed unless you have experience, and has, if missed, possibly disastrous consequences. Meanwhile, the other variant is at worst annoying.

Now one could say “just use the GUI”, but the GUI itself allows one to export the backup-job into a command line, so I don’t think one can assume that everyone who uses the CLI has said experience.

In general I assumed that standard behavior plays it safe, and that changes which might lead to worse outcomes need to be actively specified. So I’d be in favor of a notification with “–silent” as advanced option

Standard behavior does not “fail silently” (as topic subject suggests).
Non-standard situations such as discarding all the output cause that.
This is a standard problem that must be solved for a scheduled task.

The situation is a little better if you run it live at the CLI, where you can see messages.
Intentionally putting things in the background requires knowing how to know if they fail.
Running Duplicati as a Windows service faces the same challenge without a Tray Icon.

Generally people will use one of the supported notification methods if they care to hear.
Hearing does matter for anything important, but there’s a limited toolset to pass results.
Reporting options form the basics (pick some), and other mechanisms build upon them.

Favoring things does not make them possible, even aside from the resources they need.
If you want to formalize an enhancement request, the formal tracking is in GitHub Issues.

Features category in the forum is a way to see if others favor them (but read start again).
Maybe someone will think of a better solution. There are some very skilled users around.

Duplicati also supports various systems, so portable features are the best. On Windows,
Sending toast notifications from desktop apps is presumably how browsers can do these.

When you run as a scheduled task, in the background, it’s not clear if that section applies.

Windows service has a similar issue. It can run as a different user, so how to notify yours?

CommandLine operations run independently of each other and of a service/TrayIcon used.

Different ways to make a Duplicati backup gets into the flexibility (and confusion) possible.
While some backup systems are limited and simplified, Duplicati is not one such system…

duplicati-client goes even further. A now-former Duplicati developer reverse-engineered the
web interface API in order to be able to run a Server or TrayIcon from the command line…

“Test your backups” but I agree that many people don’t. An external monitor can help a little.
Even a system that doesn’t usually fail silently can be silent if it fails to run, so can’t notify…
Some monitors get schedules, so spot missed backups. I don’t know if yours is predictable.

2 Likes

Thank you both for your time & help!

I’m more or less conditioned to expect programs to be quiet when working, and loud when not. But for me the danger has come and passed, so it’s only sad for those who made the same mistake I did, as they, too, probably only after losing some files will realize their mistake. Well, given that I’m seemingly the first to make that mistake, it probably won’t hit more than a handful people.

I’ve asked to add a line in the documentation that hints towards this.

Reading the options list and keeping in mind that if the system fails to run, it can’t notify me, I’ll probably go with gpatel-fr’s solution, as I don’t trust myself to notice a regular mail not to arrive anymore and a failed server connection was the root cause of my problem. “duplicati-control.py” from the article would have been interesting as well, but I don’t think it exists anymore (at least not in Duplicati’s directory).

Nicely done, as a pull request. Thank you.