Good day.
I have several mikrotik routers which i administer remotely.
It is: CCR1016-12G(tile), RB1100AHx2(powerpc), hEX lite(mipsbe), RB2011UiAS-2HnD(mipsbe), CCR1036-12G-4S(tile), CCR1036-8G-2S+(tile).
I try to use script to backup config file on remote ftp server.
log info "Starting Automatic Backup Script"
:local ftpusername "admin"
:local ftpuserpassword "admin"
:local ftphostname "192.168.1.1"
log info "Get Date"
:global thisdate [/system clock get date]
:global thistime [/system clock get time]
:global datetimestring ([:pick $thisdate 7 11]."-".[:pick $thisdate 0 3]."-".[:pick $thisdate 4 6]."-".$thistime)
log info "Set names"
:local fname ([/system identity get name]."-".$datetimestring.".backup")
log info "$fname"
log info "Starting Backup"
# backup the data
/system backup save name="$fname"
:log info message="System backup finished.";
:log info "Please wait…!!!"
:delay 5s
:log info "Sending Backup Mikrotik to FTP Server…………."
/tool fetch address="$ftphostname" src-path="$fname" user="$ftpusername" password="$ftpuserpassword" port=21 upload=yes mode=ftp dst-path="mikrotik_backup/$fname"
:log info "Remove Files"
:delay 1
/file remove "$fname"
:log info "Finished Backup Script…!!!!"
All works fine on the router with mipsbe architecture.
There is a problem on the others routers. When script trying to upload file to ftp server - it wont upload the file or start it and then goes to error. Script going fail.
Have you tried increasing the delay between the backup and ftp? If the CPU is under load it might take longer than 5s to complete and show up in directory.
Does it work if run ftp upload command from terminal?
I have backups scripts run on CCRs and RBs and they all work ok.
Except situation then NAS is in standby mode - in this case my script fails in first retry (stops with timeout error) but succeed on second/third (then NAS woke up).
Also check ftp log on server side - may be some hint is there…
My script is little bit more complicate %) :
I split creating backups, sending them and clearing in three different scripts.
Backups created each week and their filenames put in to the queue.
Router try send them via FTP each 15 minutes (if I remember right).
Once per week old backups deleted and only last three left.
FTP:
Difference with usual fetch that script run in different thread and log file with result is created/checked i.e. I can get status - success or fail.
If you wish I can put here full source of my backup system - it is easy to install and config.