Community discussions

 
xavierdp
just joined
Topic Author
Posts: 5
Joined: Thu Sep 13, 2018 4:55 pm

Contribute backup script to FTP

Fri Feb 15, 2019 12:55 pm

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 :

Code: Select all

/system script
add name=backup
edit backup source

Paste the script :

Code: Select all

: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
Last edited by xavierdp on Tue Feb 19, 2019 11:05 am, edited 3 times in total.
 
User avatar
karlisi
Member Candidate
Member Candidate
Posts: 247
Joined: Mon May 31, 2004 8:09 am
Location: Latvia

Re: Contribute backup script to FTP  [SOLVED]

Fri Feb 15, 2019 1:11 pm

Sometimes it's good to have configuration export too:
/system backup save name=$filename password=xxxxx
:delay 3s
/export file=$filename
---
Karlis
 
xavierdp
just joined
Topic Author
Posts: 5
Joined: Thu Sep 13, 2018 4:55 pm

Re: Contribute backup script to FTP

Tue Feb 19, 2019 11:07 am

Hi Karlisi,

You are right

Who is online

Users browsing this forum: No registered users and 9 guests