What is Duplicati’s behaviour when it can’t connect to the specified FTP server for a scheduled task?
I want to use it to back up my laptop via FTP to a NAS on my home network, but I would like to know what it will do if I’m not home at the scheduled time and the FTP connection fails.
Hello @AndrewM and welcome to the forum!
I don’t have FTP set up , so can’t give details on how FTP would fail (there are also two versions available) but the general plan is that it tries as scheduled, gets what it gets, and lack of connection will result in error.
Backup only when host is reachable; retry backup that was missed due to connection issues has discussion and ways one can use Scripting options to avoid attempting backups when the environment appears wrong.
If you are security conscious and the NAS allows, you might consider SFTP. FTP is usually unencrypted and does not validate the identity of the server, so a risk of exposing FTP’s credentials or transferred data exists. Exposure risk can be relieved, respectively, by not reusing passwords, and by having Duplicati encrypt data.
If you wish to ensure you keep backups at somewhat regular intervals (regardless of connectivity) you could schedule them more frequently than needed, then set up backup retention rules to thin them out afterwards.
Thank you, I’ll look at that. There might be a better solution than my current plan:
Rather than using duplicati scheduler, I was going to use windows task scheduler to run the duplicati backup command on connection to the correct network once a day.
I would set a windows task to run once a day at a given time, with the “Start only if the following network connection is available”, and “Run task as soon as possible after a scheduled start is missed” options checked. I’ll need to do some testing to see if its also necessary to use the option to restart the task if it fails every X minutes for Y attempts.
The windows task would run a batch script containing a duplicati backup command.
How do I set up Duplicati in Windows Task Scheduler? (and maybe other posts) go into the path you suggest, however you’d probably want to make sure you have some Reporting options and maybe also logging set up.
If you come up with a nice design, the folks at the big discussion thread I mentioned earlier might like to know.
I think I solved it, maybe.
As of the Win10 Creator Update, it turns out that “Start only if the following network connection is available” is broken and undocumented, or so says stackoverflow. So instead we need to make a custom XML trigger:
<Query Id="0" Path="System">
*[System[(EventID=10000)]] and *[EventData[(Data[@Name="Name"]="YOUR-SSID-HERE")]]
This needs two tasks, one to run the backup (and disable the task), one to re-enable the backup task at a certain time each day.
First task: trigger is the custom on event XML I pasted above. Under the “General” tab, we need to select “Run whether user is logged on or not” and “Run with highest privileges” to run as administrator without a UAC popup. This task will run Powershell.exe with the following arguments:
-ExecutionPolicy Bypass <pathToScript>
Disable-ScheduledTask -TaskName "DuplicatiTask_1"
<duplicati backup command>
Second task: run once a day at the “backup after” time (say, 8PM), and enable the other task. As with the first task, this one needs “Run whether user is logged on or not” and “Run with highest privileges”. Under settings, we need to check “Run task as soon as possible after a scheduled start is missed” in case the computer is off at this time. Run Powershell.exe
-ExecutionPolicy Bypass <pathToScript>
Enable-ScheduledTask -TaskName "DuplicatiTask_1"
This should run Duplicati once per day, after 8PM, and only on connection to the specified network. I’ve tested all the pieces but not the whole thing, I’ll let you know how it goes later.
I’ve been running this for a week and can confirm it works now.
For the backup script, I’ve found duplicati client works better (GitHub - Pectojin/duplicati-client: A command line client for controlling the Duplicati Server) than running the duplicati backup command directly. This way I can later check on backup progress (running the command line backup in the background doesn’t let me see this), and it stays synced to the web UI.