System backup to ftp NAS

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 ? :slight_smile:

Thank you

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

Hello

Thank you for reply

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

O Yes, and this script don’t work :slight_smile:
RB951G-2HND 6.24



press Run script, nothing happen, in Log or FTP Server or in File on MT

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.

Hello :slight_smile:
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 :slight_smile:
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”