Running Duplicati on computer shutdown

I know, that I can setup Duplicati with a post backup script to shut down my computer after backup is finished. This is however not what I am looking for.

My computer´s power options (Windows 10, version 20H2) are set in a way, that the computer is shut down after pressing the power button.

I´m looking for a way to delay this shutdown and perform a Duplicati backup in the meantime automatically.

What can I do to achieve this?

I’m not sure this is easily achievable.

When a shutdown is initiated, Windows expects programs to close within a short timeframe. If programs do not comply, they can be forcibly terminated.

The only thing I can think of is to have something cancel the shutdown request, start a Duplicati backup, and once complete re-issue the shutdown request. Seems clunky and I am not sure it would actually work well.

In any case there is no way to accomplish this with any feature built-in to Duplicati.

I the meantime I found a solution, which seems to work pretty fine (partly).

In Group Policy Editor (gpedit.msc) I found Windows Settings > Scripts > Shutdown.
Commond files, which are stored here, are executed upon shutdown in the given order.

So I exported my Duplicati settings to a command line and stored this command in a file “Dupli.cmd”
Another command file “shutdwn.cmd” with @shutdown -s -f -t 10 as content performs the computer shutdown.

This works fine when backing up files to my local NAS.

Unfortunately it does not work, when I try to do the backup to my OneDrive cloud storage.
In Duplicati my OneDrive backup job works fine, but cmd-file with the exported command line gives an Authentification error.

So I´m not really finished.

in the meantime I got a hint from ts678, which solved the OneDrive backup problem.
(percent signs have to be doubled in cmd-files).
So backup to my OndeDrive works too.

Interesting… I would think the shutdown batch file is unnecessary since the computer is already in a shutdown phase.

I would worry about Duplicati not completing the backup fast enough and getting killed by Windows.

I did not test the procedure without shutdown.cmd, but this gives an extra option to delay shutdown.

My Windows10 shutdown settings end all open processes with a 5 seconds delay (I believe 20 seconds is Windows standard). My Duplicati backup needs about 2 minutes to perform and this is not interrupted. So I´m pretty shure that your concerns do not apply.

Oh yeah, you could be right that running shutdown with a timeout is helpful. But why is the timeout just 10 seconds (the -t 10)? Maybe you meant it to be 10 minutes?

Well, 10 seconds is just a little bit more than nothing :grinning:
I just tested the whole procedure on a spare computer. I will setup a computer in a couple of days, which is operated daily by a person with limited Windows knowledge. If problems occur during shutdown of the computer, I will have to react.

1 Like