Contribute backup script to FTP

Hi all,

I searched for a long time on the web without find it, so i grabbed codes and put my FTP backup script here for community

Create the script :
/system script
add name=backup
edit backup source
Paste the script :
:local identity [/system identity get name]
:local date [/system clock get date]
:local time [/system clock get time]
:local day [ :pick $date 4 6 ]
:local month [ :pick $date 0 3 ]
:local year [ :pick $date 7 11 ]

:local months {"jan"="01";"feb"="02";"mar"="03";"apr"="04";"may"="05";"jun"="06";"jul"="07";"aug"="08";"sep"="09";"oct"="10";"nov"="11";"dec"="12"}
:local monthr {"jan";"feb";"mar";"apr";"may";"jun";"jul";"aug";"sep";"oct";"nov";"dec"}

:set month ($months->$month)
:set time ( [:pick $time 0 2].[:pick $time 3 5].[:pick $time 6 8] )

:local filename "$identity-$year$month$day-$time"
:put $filename

backup export (with users passwords, ssh pub key, ...)

/system backup save name=$filename password=xxxxxxxx
/tool fetch mode=ftp port=21 password=xxxxxxxx keep-result=yes user=xxxxxxxx address=xxxxxxxx upload=yes src-path="/$filename.backup" dst-path="/your/path/$filename.backup"
/file remove "$filename.backup"

configuration file export

/export file=$filename
/tool fetch mode=ftp port=21 password=xxxxxxxx keep-result=yes user=xxxxxxxx address=xxxxxxxx upload=yes src-path="/$filename.rsc" dst-path="/your/path/$filename.rsc"
/file remove "$filename.rsc"

replace xxxxxxx with your codes

The filename will look like : hostname-YYYYMMDD-HHMMSS.backup


i don't find in language code list the good one : what is the right one to i change it in this post ?



Regards
Xavier

Sometimes it’s good to have configuration export too:

/system backup save name=$filename password=xxxxx
:delay 3s
/export file=$filename

Hi Karlisi,

You are right