Page 1 of 1

System backup to ftp NAS

Posted: Wed Jan 14, 2015 4:54 pm
by nemke
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

Re: System backup to ftp NAS

Posted: Wed Jan 14, 2015 6:03 pm
by hellweiss
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

Re: System backup to ftp NAS

Posted: Fri Jan 16, 2015 1:28 am
by nemke
Hello

Thank you for reply

in fetch address=192.168.88.2/Backup/Mikrotik or just fetch address=192.168.88.1 ?

Re: System backup to ftp NAS

Posted: Fri Jan 16, 2015 1:35 am
by nemke
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

Re: System backup to ftp NAS

Posted: Fri Jan 16, 2015 2:21 pm
by hellweiss
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.

Re: System backup to ftp NAS

Posted: Fri Jan 16, 2015 8:17 pm
by nemke
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"