Backup script stopped working after 7.20 update

Hi everyone!

I use several “RBD52G-5HacD2HnD” routers for years now.

Have been using this script for my daily backup of settings on all of them …

2 days ago I updated them to RouterOS to 7.20 ( from 7.19.4 )

Since then this script has stopped working with the following error in log on ALL my installations:

“invalid file name (:export; line 37)”

line 37 of my script looks like : /export show-sensitive file=($sfname.".rsc")

The complete script follows :


:local saveUserDB false
:local saveSysBackup true
:local encryptSysBackup false
:local saveRawExport true

:local FTPServer "192.168.1.1"
:local FTPPort 21
:local FTPUser "user"
:local FTPPass "pass"

:local filename;

:local date [/system clock get date];
:local time [/system clock get time];
:local name [/system identity get name];

:local varHour [:pick $time 0 2];
:local varMin [:pick $time 3 5];
:local varSec [:pick $time 6 8];

:set filename ("Backup"."".$name."".$date."_".$varHour."-".$varMin."-".$varSec);

:local sfname ("/".$filename);

:if ($saveUserDB) do={
/tool user-manager database save name=($sfname.".umb")
:log info message="User Manager DB Backup Finished"
}

:if ($saveSysBackup) do={
:if ($encryptSysBackup = true) do={ /system backup save name=($sfname.".backup") }
:if ($encryptSysBackup = false) do={ /system backup save dont-encrypt=yes name=($sfname.".backup") }
:log info message="System Backup Finished"
}

if ($saveRawExport) do={
/export show-sensitive file=($sfname.".rsc")
:log info message="Raw configuration script export Finished"
}

:delay 5s

:local backupFileName "";

:foreach backupFile in=[/file find] do={
:set backupFileName ("/".[/file get $backupFile name])
:if ([:typeof [:find $backupFileName $sfname]] != "nil") do={
/tool fetch address=$FTPServer port=$FTPPort src-path=$backupFileName user=$FTPUser mode=ftp password=$FTPPass dst-path=$backupFileName upload=yes
}
}
:delay 5s
:foreach backupFile in=[/file find] do={
:if ([:typeof [:find [/file get $backupFile name] "Backup_"]]!="nil") do={
/file remove $backupFile
}
}

:log info message="Successfully removed Temporary Backup Files"
:log info message="Automatic Backup Completed Successfully"


Any help would be appreciated!

For me this message is very clear. Check your filename.

You could try to enable "sanitize-names" property under "/console/settings" menu and see if this helps.

See changelog 7.15:

*) console - added "sanitize-names" property under "/console/settings" menu (option for replacing reserved characters with underscores for files, disabled by default);

Thank You for Your reply ...

if I add ":log info message=$filename" after setting the filename I get : Backup_PCX_2025-10-06_13-50-37

which is a reasonable filename - one I have been using on all my configurations without any error messages until this update :frowning:

looks valid. Maybe it isn't the filename but the path instead?

2 Likes

Thank You for the hint ...

I changed one line :

:local sfname ("/".$filename);

to

:local sfname ($filename);

and the script runs again as expected.

Sorry for the bother, and thanks for the time and help!

3 Likes