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

**URL:** https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306
**Category:** Support
**Created:** [April 24, 2022, 5:43pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306 "2022-04-24T17:43:11Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [April 24, 2022, 5:43pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/1 "2022-04-24T17:43:11Z")

</div>

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…

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [April 25, 2022, 8:34pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/2 "2022-04-25T20:34:36Z")

</div>

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:

```nohighlight
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.

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [April 25, 2022, 8:36pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/3 "2022-04-25T20:36:57Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![JimboJones](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/j/e5b9ba/32.png) [@JimboJones](https://forum.duplicati.com/u/JimboJones)
#### Post date: [April 26, 2022, 4:58pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/4 "2022-04-26T16:58:22Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [April 26, 2022, 5:05pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/5 "2022-04-26T17:05:49Z")

</div>

> [@JimboJones](#):
>
> Wouldn’t it just be a whole lot easier to assign a static IP to the device.

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

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [April 26, 2022, 5:22pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/6 "2022-04-26T17:22:02Z")

</div>

> [@](#):
>
> 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](https://github.com/duplicati/duplicati/issues/3651)  
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.

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [June 19, 2022, 6:19pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/7 "2022-06-19T18:19:41Z")

</div>

Does this method work when the destination is of the type: `ftp://x.x.x.x`?  
What does `new-url` parameter need to contain? The ip? The string `ftp://x.x.x.x`? Something else?  
My attempts so far have failed.

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [June 20, 2022, 6:52pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/8 "2022-06-20T18:52:13Z")

</div>

Yes, it should work fine with FTP URLs. I believe you need to include the full URL which includes authentication information. You can see what the URL should look like if you export the job as command line.

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [June 20, 2022, 7:19pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/9 "2022-06-20T19:19:22Z")

</div>

Thank you for your reply.  
I did as you said but without success. This is the content of my bat script. Is there something wrong?

```nohighlight
@ping 192.168.0.93 -n 1 -w 100>nul || goto :pingerror

@goto :eof

:pingerror
@echo --remoteurl=ftp://192.168.1.93:2121/\duplicati\documenti?auth-username=xxx^&auth-password=xxx
@goto eof

:eof
@exit /b

```

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [June 20, 2022, 7:32pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/10 "2022-06-20T19:32:59Z")

</div>

I encountered a very very strange thing (for me).  
I tried to run the backup job from the command line. It worked.  
But when I tried to run it from the Duplicati gui (`http://localhost:8200/ngax/index.html#/`) it continues to give the error:  
`Failed: Impossibile effettuare la connessione al server remoto.`

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [June 20, 2022, 8:00pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/11 "2022-06-20T20:00:54Z")

</div>

> [@rinaldi6109](#):
>
> I did as you said but without success.

Unfortunately the ping test on Windows doesn’t produce consistent error result. It will return “success” with “destination host unreachable” for instance.

You might be able to use something besides ping. Or if you want to use ping you might be able to adjust the approach per this post: [Feature-Request: Start backup only if some host is available - #6 by ts678](https://forum.duplicati.com/t/feature-request-start-backup-only-if-some-host-is-available/11169/6)

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [June 20, 2022, 8:23pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/12 "2022-06-20T20:23:42Z")

</div>

I think that the source of the issue lies elsewhere because even if I reduce the script to the following line:

```nohighlight
@echo --remoteurl=ftp://192.168.1.93:2121/\duplicati\documenti?auth-username=xxx^&auth-password=xxx

```

the backup job continues to give the previous error.  
When I run it from the command line, it run successfully.

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [June 20, 2022, 8:50pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/13 "2022-06-20T20:50:59Z")

</div>

Ok maybe…

Do you have any special characters in your username or password, like `%` ?

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [June 20, 2022, 9:11pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/14 "2022-06-20T21:11:48Z")

</div>

> [@drwtsn32](#):
>
> Do you have any special characters in your username or password, like `%` ?

No. They contain only letters and numbers.  
The only _special_ character in the echo command line is ^ that I was forced to use before & otherwise it considers it as a space.

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [June 20, 2022, 10:12pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/15 "2022-06-20T22:12:39Z")

</div>

Ok, are you sure the ping test is doing as you expect? If the ping test didn’t work, then your destination is never really changed and your backup would fail because it still tries to go to 192.168.0.93.

It might help to add a debug line in your script. Something as simple as:

```nohighlight
:pingerror
echo pingerror occurred > c:\path\test.log
@echo --remoteurl= ......
....

```

might help confirm that the test is working.

---

<div class="post-metadata">

### Author: ![Xavron](https://forum.duplicati.com/user_avatar/forum.duplicati.com/xavron/32/5539_2.png) [@Xavron](https://forum.duplicati.com/u/Xavron)
#### Post date: [June 20, 2022, 10:28pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/16 "2022-06-20T22:28:37Z")

</div>

I’m confused. Can’t you just lock your portable device to use one ssid and / or be statically assigned by the router?

The same thing happens eg with backing up to Android and having the device use multiple ssid’s as each ssid may provide a different ip. The fix is to make it static and only have one ssid in use so its always the same no matter what.

It might be very interesting to make one backup task in Duplicati go to multiple ips. I’d probably use that. Wouldn’t go out of my way to do that though.

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [June 21, 2022, 6:02am UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/17 "2022-06-21T06:02:02Z")

</div>

The current version of my batch script has only the echo line, no ping at all.

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [June 21, 2022, 7:37pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/18 "2022-06-21T19:37:14Z")

</div>

Oh, gotcha.

This is kind of a stab in the dark, but what happens if you only use forward slashes? I don’t think backslashes should be in the URL:

```nohighlight
@echo --remoteurl=ftp://192.168.1.93:2121/duplicati/documenti?auth-username=xxx^&auth-password=xxx

```

---

<div class="post-metadata">

### Author: ![rinaldi6109](https://forum.duplicati.com/letter_avatar_proxy/v4/letter/r/439d5e/32.png) [@rinaldi6109](https://forum.duplicati.com/u/rinaldi6109)
#### Post date: [June 23, 2022, 8:39am UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/19 "2022-06-23T08:39:49Z")

</div>

I’ve found the cause of the issue. The batch script was never executed (when the backup job was launched from the Duplicati GUI; from the command line, all worked regularly, and this is a mystery yet).  
I firstly set c:%HOMEPATH%\Documents\checkftp.bat for --run-script-before.  
Then I tried c:\users\myname\Documents\checkftp.bat; and the issue has disappeared.  
Evidently using an environment variable is not properly interpreted.

Anyway, thanks for your help and your patience.

---

<div class="post-metadata">

### Author: ![drwtsn32](https://forum.duplicati.com/user_avatar/forum.duplicati.com/drwtsn32/32/2591_2.png) [@drwtsn32](https://forum.duplicati.com/u/drwtsn32)
#### Post date: [June 23, 2022, 2:28pm UTC](https://forum.duplicati.com/t/backup-to-a-destination-having-two-possible-addresses-is-it-possible/14306/20 "2022-06-23T14:28:18Z")

</div>

Glad you figured it out - thanks for the follow-up!
