99. Mikrotik Backup and Export Configuration to FTP Server




You can contact me: plus.google.com/+PhallaCCMT; youtube.com/phallaccmt; facebook.com/Phalla.CCMT; twitter.com/PhallaCCMT and Phalla.CCMT@gmail.com

Script:
# ftp server
 :local ftphost "192.168.9.100"
 :local ftpuser "test"
 :local ftppassword "test"
 :local ftppath "/home/test"

#GetDate
:local GDate [/system clock get date]
:local GDay [ :pick $GDate 4 6 ]
:local GMonth [ :pick $GDate 0 3 ]
:local GYear [ :pick $GDate 7 11 ]
:local GResult "$GDay $GMonth $GYear"


# file name for user manager backup
:local UserMan ([/system identity get name].".umb")
:log info $UserMan

# file name for system backup
:local BackupConf ([/system identity get name].".backup")
:log info $BackupConf

# file name for config export
:local ExportConf ([/system identity get name].".rsc")
:log info $ExportConf

# backup the data
/tool user-manager database save name=$UserMan overwrite=yes
:log info message="User manager backup finished (1/3).";
/system backup save name=$BackupConf
:log info message="System backup finished (2/3).";
/export compact file=$ExportConf
: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=$UserMan user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$GResult-$UserMan" upload=yes

# upload the system backup
:log info message="Uploading system backup (2/3)."
/tool fetch address="$ftphost" src-path=$BackupConf user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$GResult-$BackupConf" upload=yes

# upload the config export
:log info message="Uploading config export (3/3)."
/tool fetch address="$ftphost" src-path=$ExportConf user="$ftpuser" mode=ftp password="$ftppassword" dst-path="$ftppath/$GResult-$ExportConf" upload=yes

# delay time to finish the upload - increase it if your backup file is big
:delay 3s;

:log info message="Configuration backup finished.";



Ref: http://harry.subnetworx.de/2013/12/27/automated-routeros-backup-ftp/

Previous
Next Post »

2 comments

Write comments
Mike
AUTHOR
August 1, 2017 at 7:19 AM delete

I tried this and all I get is log message "script, info 'systemname'.umb". It doesn't even create the files locally. What could be the cause of this?

Reply
avatar
RH SHAKIB
AUTHOR
September 11, 2023 at 7:57 PM delete

Thanks its working for me.

Reply
avatar