Community discussions

 
roswitina
newbie
Topic Author
Posts: 26
Joined: Tue Mar 12, 2013 8:12 am

[resolved] Script Failure since 6.40RC38

Mon Jul 17, 2017 5:15 pm

I use the following script for backup:
# automated backup 2 External ftp
# from: http://harry.subnetworx.de/2013/12/27/automated-routeros-backup-ftp/

# ftp configuration
:local ftphost "x.x.x.x"
:local ftpuser "xxxx"
:local ftppassword "****"
:local ftppath "path"

# months array
:local months ("jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec");

# get time
:local ts [/system clock get time]
:set ts ([:pick $ts 0 2].[:pick $ts 3 5].[:pick $ts 6 8])

# get Date
:local ds [/system clock get date]
# convert name of month to number
:local month [ :pick $ds 0 3 ];
:local mm ([ :find $months $month -1 ] + 1);
:if ($mm < 10) do={ :set mm ("0" . $mm); }
# set $ds to format YYYY-MM-DD
:set ds ([:pick $ds 7 11] . $mm . [:pick $ds 4 6])

# file name for user manager backup - file name will be UMDB-servername-date-time.umb
:local fname ("/UPC-".[/system identity get name]."-".$ds."-".$ts.".umb")
# file name for system backup - file name will be UMDB-servername-date-time.backup
:local fname1 ("/UPC-".[/system identity get name]."-".$ds."-".$ts.".backup")
# file name for config export - file name will be UMDB-servername-date-time.rsc
:local fname2 ("/UPC-".[/system identity get name]."-".$ds."-".$ts.".rsc")

# backup the data
/tool user-manager database save name=$fname			## FAILURE##
:log info message="User manager backup finished (1/3).";
/system backup save name=$fname1
:log info message="System backup finished (2/3).";
/export compact file=$fname2
:log info message="Config export finished (3/3)."

# upload the user manager backup
:log info message="Uploading user manager backup (1/3)."
/tool fetch address="$ftphost" src-path=$fname user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname" upload=yes
# upload the system backup
:log info message="Uploading system backup (2/3)."
/tool fetch address="$ftphost" src-path=$fname1 user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname1" upload=yes
# upload the config export
:log info message="Uploading config export (3/3)."
/tool fetch address="$ftphost" src-path=$fname2 user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$fname2" upload=yes

# delay time to finish the upload - increase it if your backup file is big
:delay 60s;
# find file name start with UMDB- then remove
:foreach i in=[/file find] do={ :if ([:typeof [:find [/file get $i name] "UMDB-"]]!="nil") do={/file remove $i}; }
:log info message="Configuration backup finished.";
This script has worked up to version 6.40RC36. From version 6.40RC38, the following lines no longer work:

/ tool user-manager databaseSaveName = $ fname
: log info message = "Uploading user manager backup (1/3)."
/ filename = ftp password = "$ ftppassword" dst-path = "$ ftppath / $ fname" upload = yes

The log shows:
Memory Script, error Sript error: File already exist!

When I excerpt these lines, the script runs through.

Rosi
Last edited by roswitina on Mon Jul 17, 2017 6:51 pm, edited 1 time in total.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 5942
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Script Failure since 6.40RC38

Mon Jul 17, 2017 6:34 pm

please try rc41
 
roswitina
newbie
Topic Author
Posts: 26
Joined: Tue Mar 12, 2013 8:12 am

Re: Script Failure since 6.40RC38

Mon Jul 17, 2017 6:50 pm

Script runs again. Thank you.
Rosi

Who is online

Users browsing this forum: No registered users and 11 guests