Backup to a destination having two possible addresses, is it possible?

One of my backup job saves to a portable device which doesn’t always have the same IP in my lan (It is complicated for me to write a proper explanation for this).
Say sometime it has ip 192.168.0.100 and sometimes 192.168.0.200.
So, I ask: is there any way to set up a job with destination 192.168.0.100 and in case this IP is not reachable to change it with 192.168.0.200?
At first I thought to write a run-script-before-required script altering the hosts file, but this task is intricate and it requires adminstrator privileges and so I stopped myself in the hope that a simpler solution is possible…

One way you could do this is with --run-script-before and have the script issue a new --remoteurl based on some test (ping, file present, etc). To change that you’d use the echo command like this:

echo --remoteurl=new-url

So you’d construct some sort of test and echo that only if the backup destination is in the alternate location. Otherwise don’t echo anything and Duplicati will use the remote url as defined in the backup job.

If the destination is using regular SMB, you might be able to use the --alternate-destination-marker and --alternate-target-paths instead. The options were designed for local paths but they might work for UNC/SMB.

Wouldn’t it just be a whole lot easier to assign a static IP to the device. Currently it’s configured for DHCP which is why it’s getting an IP between .100 and .200 (the range of you DHCP scope, likely defined in your router, not that this is a router issue).

When you assign a static IP it should be outside of the DHCP scope or strange conflicts can occur. In your case you should be using an IP between 192.168.0.2 - 192.168.0.99 or 192.168.0.201 - 192.168.0.254. 192.168.0.1 is excluded above as by default that will be the routers IP address.

Before setting a static IP verify that no other devices on the network are using that IP by pinging the candidate address and verifying that you DO NOT get a reply back, which 99% of the time confirms that address is not already in use.

If you have other questions ask away.

My guess was that he is connecting a portable device to different host machines that have different IPs.

Not exactly, but you’re right thinking that I cannot solve the issue setting a static IP.
My situation resembles the one described at page --REMOTEURL ignored in --run-script-before script · Issue #3651 · duplicati/duplicati · GitHub
which I have discovered after your replies searching google for “remoteurl” (poorly documented imho).
Anyway, thank you for your hints. they address me in the right direction.

1 Like