Community discussions

MikroTik App
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Thu Jul 31, 2014 2:52 am

System backup to ftp NAS

Wed Jan 14, 2015 4:54 pm

Hello guys

Can someone help me.

I need to setup my MT to do system backup to my NAS over FTP.

So idea is this, once a week (exemple every Friday at 00h) MT need to do system backup and to export "name".backup file to Local NAS ftp://192.168.88.2/Mikrotik/Backup/ and after that do delete same file from MT memory.

I try to find some script but any of those doesn't work...
So someone can help ? :-)

Thank you
 
hellweiss
newbie
Posts: 35
Joined: Thu Sep 02, 2010 10:36 am

Re: System backup to ftp NAS

Wed Jan 14, 2015 6:03 pm

We use something like this:
/system backup save name=[/system identity get name] dont-encrypt=yes
delay 10
/export file=[/system identity get name]
delay 10
/fetch address=IP_OF_NAS src-path=([/system identity get name].".rsc") mode=ftp user=FTPUSER \
password=FTPPASSWD upload=yes dest-path=([/system identity get name].".rsc")
/fetch address=IP_OF_NAS src-path=([/system identity get name].".backup") mode=ftp user=FTPUSER \
password=FTPPASSWD upload=yes dest-path=([/system identity get name].".backup")
/log info message="System Backup"
Hope this helps.

[EDIT] added some brackets and slash
Last edited by hellweiss on Fri Jan 16, 2015 2:27 pm, edited 2 times in total.
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Thu Jul 31, 2014 2:52 am

Re: System backup to ftp NAS

Fri Jan 16, 2015 1:28 am

Hello

Thank you for reply

in fetch address=192.168.88.2/Backup/Mikrotik or just fetch address=192.168.88.1 ?
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Thu Jul 31, 2014 2:52 am

Re: System backup to ftp NAS

Fri Jan 16, 2015 1:35 am

O Yes, and this script don't work :-)
RB951G-2HND 6.24



press Run script, nothing happen, in Log or FTP Server or in File on MT
 
hellweiss
newbie
Posts: 35
Joined: Thu Sep 02, 2010 10:36 am

Re: System backup to ftp NAS

Fri Jan 16, 2015 2:21 pm

Just fetch Address 192.168.88.2
You have to give the right policy in /system script
Try with all policy enabled first.

Do you see the files hostname.backup and hostname.rsc with actual Timestamp in the Files Menu ?

You can try to copy every single line in a Terminal window and see, where the error is.

I have added some brackets in the Script above. Should work now.
 
nemke
Member Candidate
Member Candidate
Topic Author
Posts: 160
Joined: Thu Jul 31, 2014 2:52 am

Re: System backup to ftp NAS

Fri Jan 16, 2015 8:17 pm

Hello :-)
I find some scripts on net and combine some part of it, and got this, all work fine, and Logs shows messages.
Just change red fields to custom your system, and all work fine :-)
I lost few hours to make it work, because not even one script that I find on net would not work, but it is good now...
Thank for help.

:local time [/system clock get time];
:local date ([:pick [/system clock get date] 0 3] \
. [:pick [/system clock get date] 4 6] \
. [:pick [/system clock get date] 7 11]);
:local filename "$hostname-$date-$time";

# Create backup file and export the config.

export compact file="123456.backup"
/system backup save name="123456"

:log info "Backup Created Successfully"

# delay time to finish the create - increase it if your backup file is big
:delay 15s

# Upload backup file to FTP server.

/tool fetch address=192.168.88.2 src-path="123456.backup" \
user=xxxxx mode=ftp password=xxxxx \
dst-path=/Backup/Mikrotik/123456.backup upload=yes port=21

:log info "Backup Uploaded Successfully"

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

# Delete created backup files once they have been uploaded
# so they don't accumulate and fill up storage space on the router.

/file remove "123456.backup.rsc"
/file remove "123456.backup"

:log info "Local Backup Files Deleted Successfully"

Who is online

Users browsing this forum: Google [Bot], GoogleOther [Bot] and 183 guests