Scheduled backup didn't start

I created a backup task to run daily at 23:00.
The UI confirms the “Next scheduled run: Today at 23:00”
The problem is that the backup job didn’t run as scheduled; it did run when I woke the PC next morning, which of course is standard behaviour.

I don’t understand why the backup didn’t run as scheduled.
I thought it might be because the PC is set to sleep after a period of inactivity, but I’ve had other backup software that ran as scheduled when the PC was asleep, so I’m at a loss.

I don’t have any wake-up scripts or anything like that and I don’t have any other jobs scheduled, so any help would be much appreciated.

I had a thought after posting that if the PC went to sleep AND logged me out, would this prevent the backup job from starting? If so how do I get it to start as scheduled?

AND, I have Duplicati as an application not a service. I don’t know if that makes a difference.

Hello

an application running in your session will not work when you are logged out. As of the PC sleeping, it’ complicated and depends on the system.
While I have never tried that, I guess that if a Windows PC sleeps but you have scheduled a wake up as a Windows event, the service will start to run, finds that it missed a backup and start it. Then it will prevent Windows to sleep again while the backup is running. Once the backup is finished, the PC will be able to go to sleep again. That’s the theory at least.

I don’t think Duplicati provides a feature to wake the PC.

You may need one, and it might need to run an Export As Command-line, because …

Windows tends to wake at night. Roughly 3 A.M is a favorite time, per web search and

Task Scheduler Library → Microsoft → Windows → UpdateOrchestrator

image

You can use Nirsoft LastActivityView to see everything that jumped in at that opportunity.
Duplicati doesn’t, and I’m assuming it’s because .NET Framework isn’t giving it an event:

System Wake-up Events is supposedly what happens at Win32 API, but I don’t debug at that level.
Actually I haven’t put a debugger on the code snippet above either, but I’m assuming it didn’t fire…

On a VM I use for testing, this task is disabled, and it is setup to not run when the system sleeps.

A possibility is that Duplicati don’t run because the Duplicati scheduler runs with a granularity of 5 minutes while Windows waits only 2 minutes to give background tasks a chance to run. You could try to setup a task waking up your PC to run a (powershell) script running ‘sleep 360’ to see if Duplicati is starting a delayed backup at this moment.

The link I cited says that the 2 minutes is so that they can say they’re busy.

My system was awake for 7:24 this morning per powercfg.exe /SleepStudy
and the profiling log on my hourly (while awake) backup showed no activity.

2023-04-24 20:51:36 -04 - [Profiling-Timer.Finished-Duplicati.Library.Main.Controller-RunBackup]: Running Backup took 0:00:01:32.322
2023-04-25 06:13:50 -04 - [Information-Duplicati.Library.Main.Controller-StartingOperation]: The operation Backup has started

I’ll leave it to the person seeking wake-and-run to explore as they’re willing.
I’m happy to let my hourly take a break, but an after-hours daily is different.
There might be a feature request here. I don’t recall if others asked for this.

The code in SystemEvents_PowerModeChanged is unclear (as often):

//If we have been been paused due to suspending, we un-pause now

however this is not quite what happens really, there is this calculation between the sleep time and the resume time that seems to set a pause of equal duration. Why ? mystery, no explanation :frowning: . The comment says: we unpause now. Not true.

I see no good reason if say the system was put to sleep at 22h (I am referring to 24 hours days) and it wakes up at 3 in the morning to calculate 5 hours (22 to 3) and do a pause of the same duration. This is not making sense to me.

If you mean this calculation:

then see below, which probably refers to GUI Settings → Pause after startup or hibernation:

As for the comment, it’s correct in its large print, but doesn’t quite capture the full calculation.
Sometimes comments aren’t precisely accurate. Does above look right from C# code reads?

EDIT:

Also look at EstimatedPauseEnd math and use.

EDIT 2:

About → System info has some info. Here, I see it counting off a 10 minute delay in Settings:

Server state properties

estimatedPauseEnd : 2023-04-25T16:43:17.936278-04:00

programState : Paused

pauseTimeRemain : 517495

I see in the commit:

commit 127486b1dec0f31b85c50294269b259f3fdb4346
Author: kenneth@hexad.dk <kenneth@hexad.dk@59da171f-624f-0410-aa54-27559c288bec>
Date:   Fri Jun 29 19:24:21 2012 +0000

    Added support for detecting hibernation/suspend on Windows.
    When coming out of a hibernation/standby Duplicati will now be in pause mode for the same duration as on startup.
    If a pause has been requested by the user (i.e. pause for 1 hour), the pause after hibernation will be at least the startup duration period, but at least as long as the pause duration would have been without a hibernation/suspend.

so the intention is that there is a pause on resume only if the app was paused (explicitly) when sleeping. As this is done at the Win32 Api level, I don’t quite see why the C# would block it. I don’t quite see either why you are seeing a 10 minutes delay (or none, or more…I am missing the context)

Context is GUI Settings → Pause after startup or hibernation as mentioned earlier. I set 10 minutes.
After a manual sleep and a manual resume, there were minutes left. By code and above, it delayed.

The System Wake-up Events link above explains how Win32 handles automatic and user differently.
Both do PBT_APMRESUMEAUTOMATIC event. User adds a PBT_APMRESUMESUSPEND event. These are WM_POWERBROADCAST message and one sees the automatic versus user difference.

The handler code for this inside .NET Framework 4.8 looks to be here, and looks like it sets Resume based on certain events, including PBT_APMRESUMESUSPEND but not from PBT_APMRESUMEAUTOMATIC which seems kind of consistent with the “most applications should do nothing” said in the Events link.

EDIT:

Or maybe the comment you found meant the Pause control at top of GUI. That also has a timer on it.
Maybe the same code is run to prevent going active in contradiction to either GUI control or Settings.

image

It may be possible that when the system ‘sleeps’ but can be woken up to do work like updates, its state is really standby, not sleeping.

Seems unlikely, but be careful of terminology. If you’re thinking Modern Standby, this looks like S3/S4 which is called hybrid because it’s suspend to RAM plus a hibernate file kept in case power goes out.

Additionally the System event log is talking about S3 and S4, and the machine predates Windows 8.1 which did Connected Standby which preceded Modern Standby, so probably lacks the newer flavors.

Modern Standby is also described as an instant on / instant off, and that’s rather far from what I have.
Nirsoft TurnedOnTimesView classifies my ShutdownType as Sleep, so there’s another vote for Sleep.

It’s a good question for other systems though, although I’m not sure why we need to divert into it now.
To understand user situations better, one possible enhancement would be to log the incoming events.
With that, we would know for sure what event .NET Framework sent, or if the code I cited didn’t do so.

EDIT:

Here’s how to allow hybrid sleep and hardware wake timers to wake this desktop up to check updates:

image

EDIT 2:

The Events link says it applies to S3/S4, so I think it explains my system’s behavior perfectly, where automatic resume does not inform Duplicati but manual resume does, thanks to code that I showed.
I’m not seeing where Modern Standby sends such events. After all it’s still in S0, but at lower power. Maybe this would be an explanation for those who find pause on resume is ignored, but mine works.

EDIT 3:

C:\>powercfg.exe /availablesleepstates
The following sleep states are available on this system:
    Standby (S3)
    Hibernate
    Hybrid Sleep
    Fast Startup

The following sleep states are not available on this system:
    Standby (S1)
        The system firmware does not support this standby state.

    Standby (S2)
        The system firmware does not support this standby state.

    Standby (S0 Low Power Idle)
        The system firmware does not support this standby state.


C:\>

It looks like “standby” and “sleep” are pretty much mixed here, but that last one is Modern Standby.

Thanks for the input.
Following on from this suggestion I set up a very simple Scheduler test task to run Notepad.exe at a predetermined time.
I then put the PC to sleep.
At the predetermined time the PC woke up and Notepad had started.

I then edited the task and replaced “Notepad” with a small test backup job that I created and “exported as a command line” as suggested.
The first difference I noticed is that the Task Scheduler now prompted me for my user id and password before saving the task.
Secondly, at the predetermined time the PC woke up but the backup job did not start.
The History tab in the Task Scheduler didn’t show any errors.

I do not understand why Notepad started but Diplicati didn’t.

I’m no Task Scheduler wizard, so if anybody is, please jump in. Task Scheduler is often tough for me.

Although I did once see it ask for user id and password (and then reject them), now I’m running Task Scheduler as myself (instead of an Administrators group user), and having no prompts for either one.

I don’t know if you put the command line export into a .bat file, but I did. You could add debug lines if you’re not sure if yours is running, for example echo some progress statements to a file you can write.

I’m also not initially worrying about waking the system (which seems to work for you), or running when user isn’t logged in (which you might care about). It was a rather basic task with a lot of defaults taken.

Because command line jobs run independently of the GUI, you’ll have to do something like going into Logs on the GUI to see if anything ran. It’s not going to refresh the home page statistics automatically.

EDIT:

Of course you can also do things like send email or an HTTP post somewhere. It’s especially useful to learn about errors, because you won’t have a visible TrayIcon to change colors when something’s bad.