Thursday, September 1, 2016

script to backup mikrotik configuration file and raw configuration file

***setup information***
ftp server address:
user: ftp2
file name formate: BACKUP-routerName-Date-Time dot (backup or rsc)

setup ftp server you can follow link below

-- script

:local FTPServer ""
:local FTPPort 21
:local FTPUser "ftp2"
:local FTPPass "test123"

:local ds [/system clock get date]
:local iname [/system identity get name]
:set ds ([:pick $ds 7 11].[:pick $ds 0 3].[:pick $ds 4 6])

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

:local fname ("BACKUP-".$iname."-".$ds."-".$ts)

/system backup save name=$fname
/export file=$fname

/tool fetch address=$FTPServer port=$FTPPort src-path=($fname.".backup") user=$FTPUser mode=ftp password=$FTPPass dst-path=($fname.".backup") upload=yes

/tool fetch address=$FTPServer port=$FTPPort src-path=($fname.".rsc") user=$FTPUser mode=ftp password=$FTPPass dst-path=($fname.".rsc") upload=yes

:log info message="Successfully backup configuration files"

- screenshot of mikrotik log and file on ftp server

No comments:

Post a Comment