it would be great, if there is a feature, so that a backup is only started, if a specified host is available.
Background: I am using duplicati on my laptop. But sometimes I have no or a limited internet connection. So the backup should wait until my backup server is available.
Thanks in advance
Welcome to the forum!
You can do this with –run-script-before and a custom errorlevel for the batch file. Errorlevel 1 is probably what you want unless you want a warning/error to be triggered:
Errorlevel 0: Everything is OK, start backup task
Errorlevel 1: Everything is OK, but don't run the backup
Errorlevel 2: There is something wrong, raise ParsedResult to Warning, add script output to Warning section in Result file. Run the backup.
Errorlevel 3: There is something wrong, raise ParsedResult to Warning, add script output to Warning section in Result file. Don't run the backup.
Errorlevel 4: There is something wrong, raise ParsedResult to Failed, add script output to Error section in Result file. Run the backup.
Errorlevel 5: There is something wrong, raise ParsedResult to Failed, add script output to Error section in Result file. Don't run the backup.
Is this on Windows? Here’s an example of what to put in your batch file:
ping -n 2 hostname || exit 1
Edit: ping on Windows doesn’t seem to return a testable error code, so the above actually doesn’t work. ping works as a test on Linux, though. For Windows you’ll want to use something else.
i have the same Problem like [tkn777] but the solution from [drwtsn32] dont work for me. I also use duplicati on my laptop.
I would like the backup to start automatically when I’m at home (e.g. via a certain wlan ssid)
Also the option that the backup only starts when the laptop is connected to the power would be useful.
Also the option that a backup is made when a USB stick with a certain name is connected would be useful. alternatively, a certain file could be stored on the usb stick to check whether the correct stick is connected. but please not with “–run-script-before” that is too complicated for many people.
For me, duplicati is already the best backup program, but many other backup programs have these options, it would be great if duplicati becomes more user-friendly.
I’m curious as to why it didn’t work. Do you need help developing a pre-backup script? Can you show me what you tried?
I was revisiting this and just realized my ping example doesn’t work on Windows! Something similar works on Linux, and I incorrectly assumed it would also work with Windows. Unfortunately ping on Windows doesn’t seem to return a testable error condition.
So you’ll probably want to use something besides ping to do the test on Windows.
It does, but not the way I’d prefer. It’s thrown off by things like “Destination host unreachable” responses.
Destination host unreachable, but the errorlevel is 0 (from a win7) [closed] links to Ping Errorlevel script.
Or if you trust my shaky Command Prompt skills, a one-liner demo similar to the original might be to do:
ping -n 1 hostname | find “Reply” > NUL || exit 1
I think the “Destination host unreachable” oddity is relevant to hosts on local network. Is that your case?
If so, maybe look-for-an-actual-Reply fix will help. If not, then I’m not sure exactly what the situation is…
I don’t think there’s normally a guarantee of the Windows drive letter the USB stick will receive, but see
Windows Drive Letters which describes the Local folder or drive options
alternate-target-paths to handle the potentially changing drive letter, and
alternate-destination-marker for your “certain file”.
It’s not an automatic start, has no friendly GUI, but is a start. Look for related forum topics for more info.
This is all limited by lack of new developers to add things… Volunteers are also encouraged in all areas.
Ah, you’re right. If I only get “request timed out” then it works. Or if DNS resolution fails it works.