Thursday, September 1, 2016

script to backup mikrotik configuration file and raw configuration file

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

setup ftp server you can follow link below
http://www.atechnote.com/2016/08/setup-pure-ftpd-server-with-mysql.html



-- script


:local FTPServer "192.168.202.33"
: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