Backup failing over ftp

Hi everyone,

Im running a script on routers which backs up configuration over ftp, all of them are connected over wireguard site to site vpn.

all of the routers succefully upload files, but for some reason one of them is reporting failure in logs, but also uploads part of the file. it generates 64Kb file and file on ftp server is only 10Kb

here are the lines from log

executing script FTP-Backup from winbox failed, please check it manually

failure: connection timeout (/tool/fetch; line 8)

router is rb5009

for test purposes I ran the same script on CRS326 which is behind the router in question and it reported Upload to 172.17.0.7 FINISHED

here is the script I created with help of grok

:local id [/system identity get name]

:local fname ($id . "-" . [:pick [/system clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system clock get date] 4 6] . "-" . [:pick [/system clock get time] 0 8])

/system backup save name=("$fname.backup") password=""

/export terse file=("$fname.rsc")

:delay 10s

/tool fetch address=172.17.0.7 user=******** password=********* mode=ftp \

src-path=($fname . ".backup") dst-path=("Router-Backup/" . $fname . ".backup") upload=yes keep-result=no

/file remove [find name=("$fname.backup")]

/file remove [find name=("$fname.rsc")]

What is the system identity of that router?

Is it running a different RouterOS version than the others?

RB5009 was running 7.20.1 update to 7.20.4 didn’t resolve an issue

I’m puzzled. Out of 4 remote RB5009 routers one is failing to upload full file, no matter how many times I run the script it uploads exactly 10.69KB out of 69.2 saved to the flash

I just tried another router L009UiGS running 7.20.4 with the same failure. Out of 80.4KB only 12.02 makes to FTP. Out of curiosity i ran the script on older cAP ac with version 6.49.19 and it executed perfectly, it even deleted backup files from flash, which is not working on newer devices

I use a similar script, but on other routers, and without using dates or deleting files, I simply overwrite them in the router and on FTP. My devices are in the screenshot.

Your script, by the way, doesn't parse the date correctly, as far as I understand, so the files turn out like this:
--21202-1-10:30:52 Try my script on problematic routers. I have FTP on port 8021, change it to your port

:local backupfilename ([/system identity get name])

:local ftpusername "backup"

:local ftpuserpassword "backup"

:local ftphostname "172.17.0.7"

/system backup save name="$backupfilename"

:delay 5s

/export compact file="$backupfilename"

:delay 5s

/tool fetch address="$ftphostname" src-path="$backupfilename.backup" user="$ftpusername" password="$ftpuserpassword" port=8021 upload=yes mode=ftp dst-path="$backupfilename.backup"
:delay 1s

/tool fetch address="$ftphostname" src-path="$backupfilename.rsc" user="$ftpusername" password="$ftpuserpassword" port=8021 upload=yes mode=ftp dst-path="$backupfilename.rsc"

I asked about the identity of the device to see if there are special characters in it.

Now I look closer I see you also included the time, that contains : also a special character.

From a certain version of RouterOS, there is a check for special characters and scripts like yours can cause problems.

thank you for trying, but your script didnt work where i had mine partially working

it generetes files and overwrites them as you mentioned, but doest make it to ftp, not even partially

Then try downgrading to 7.19.4 or 7.19.6, there are a lot of (different, but you never know) reported issues with 7.20.x and particularly with 7.20.4.

identity is simple text without spaces or charachters.

part of the file gets there somehow

Ive tried changing ports and settings on ftp server

compared firewall settings on working vs non working identical routers

checked wireguard settings

I pretty much matched everything i could think of and still same result

it does work on 7.20.x on one router and not on another identical one with same ros.

got to be something else. not the script and not OS version

AFAIK there are four things that can lead to different results of commands, differences can be related to:

  1. Device models
  2. RoS versions
  3. Hardware faults (on one of the two devices)
  4. Configurations

So, once excluded #1 and #2, #3 is possible but less probable than #4.

I noticed that export compact terse is very slow after updating to 7.20.2

I don't know why.