Community discussions

MikroTik App
 
darkoknght
just joined
Topic Author
Posts: 20
Joined: Fri Oct 06, 2017 5:09 am

How to send a backup to email

Fri Oct 13, 2017 4:12 pm

hello everybody ;
is there a way to set a rule or something to send back up to email automatically like everyday ? and does it send a backup even if the password of mikrotik has changed ?
 
Shadeofspirit
Member Candidate
Member Candidate
Posts: 203
Joined: Fri May 27, 2016 12:15 am
Location: Minsk
Contact:

Re: How to send a backup to email

Fri Oct 13, 2017 4:34 pm

hello everybody ;
is there a way to set a rule or something to send back up to email automatically like everyday ? and does it send a backup even if the password of mikrotik has changed ?
in Tools-Email put credentials to e-mail
create script:
/export file="config"
/tool e-mail send to=email_to_send@domain.com subject="config export " file="config.rsc"
put this script in scheduler

it will send backup even if you will change password
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1495
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: How to send a backup to email  [SOLVED]

Fri Oct 13, 2017 6:19 pm

I do this every night on both my routers. Here is the script that I use.
/system script
add name="Daily Backup" owner=Admin policy=ftp,read,policy,test,sensitive \
    source="# Policies needed:  ftp, read, policy, sensitive, test\r\
    \n# Policies NOT needed:  password, reboot, write, sniff, romon\r\
    \n:log info \"Starting daily backup\";\r\
    \n/system backup save name=RB750-1_Daily\r\
    \n:delay 00:00:01\r\
    \n/tool e-mail send file=RB750-1_Daily.backup to=\"my_E-Mail@address\" body=\"\
    Router #1 daily backup file attached.\" \\\r\
    \n   subject=\"RB750-1  \$[/system clock get date] at \$[/system clock get\
    \_time]  Backup\"\r\
    \n/ export file RB750-1_Daily\r\
    \n:delay 00:00:10\r\
    \n/tool e-mail send file=RB750-1_Daily.rsc to=\"my_E-Mail@address\" body=\"Rou\
    ter #1 daily script file attached.\" \\\r\
    \n   subject=\"RB750-1  \$[/system clock get date] at \$[/system clock get\
    \_time]  Script\"\r\
    \n:log info \"Daily backup script completed\"\r\
    \n"
To use this, the E-Mail settings for server, ID and password must have already been set:
/tool e-mail
set address=smtp.gmail.com from="Router #1" password=Redacted port=587 \
    start-tls=yes user=The_sending_address@gmail.com
I then have a scheduled event to execute the script every night:
/system scheduler
add interval=1d name="Daily backup" on-event="Daily Backup" policy=\
    ftp,read,write,policy,test,password,sniff,sensitive start-date=\
    jul/12/2016 start-time=22:31:00
Obviously in both code segments, I have redacted some sensitive information.
 
darkoknght
just joined
Topic Author
Posts: 20
Joined: Fri Oct 06, 2017 5:09 am

Re: How to send a backup to email

Sat Oct 14, 2017 3:44 pm

thank you for replaying
but lets say my router got hacked and they changed the password will it send the new password in the next backup ?
and K6ccc do i have to use these 3 scripts ? or the 1st one would do it ?
and where to paste it ? in terminal ?
 
Shadeofspirit
Member Candidate
Member Candidate
Posts: 203
Joined: Fri May 27, 2016 12:15 am
Location: Minsk
Contact:

Re: How to send a backup to email

Sat Oct 14, 2017 3:55 pm

[quote="darkoknght"]
but lets say my router got hacked and they changed the password will it send the new password in the next backup ?
/quote]
no, there are no password in config export, password can be in backup, but you also can't look for it.
as a variant you can send all *.rsc files to your mail (usually, but not always, routers a hacked by bots and they leave rcs files on router)
if you are lucky to have access to you router (even with read rights) you can transfer a script to router and it will run automatically. in script you can create a new user with admin rights
 
darkoknght
just joined
Topic Author
Posts: 20
Joined: Fri Oct 06, 2017 5:09 am

Re: How to send a backup to email

Sat Oct 14, 2017 4:02 pm

so even if i got the backup i can't read it ?
 
Shadeofspirit
Member Candidate
Member Candidate
Posts: 203
Joined: Fri May 27, 2016 12:15 am
Location: Minsk
Contact:

Re: How to send a backup to email

Sat Oct 14, 2017 4:38 pm

so even if i got the backup i can't read it ?
yes, you can't read user password because of security reasons.
but if you have a backup (or config export) with last configuration you can rather fast reset your device and restore actual configuration
 
User avatar
tomaskir
Trainer
Trainer
Posts: 1162
Joined: Sat Sep 24, 2011 2:32 pm
Location: Slovakia

Re: How to send a backup to email

Sat Oct 14, 2017 5:00 pm

Sending backups to email is bad for multiple reasons.
Security, scalability, management (imagine you need to change the email address, or email credentials on 100 devices), etc.

You should look at a proper backup solution, such as Unimus, Rancid or Oxidized.
 
darkoknght
just joined
Topic Author
Posts: 20
Joined: Fri Oct 06, 2017 5:09 am

Re: How to send a backup to email

Sat Oct 14, 2017 5:37 pm

yeah i guess you are right but it would really be nice to have a backup like every 12 or 24 hours so what ever happens you can roll back 12 or 24 hours only and i will check out the links but which one is the best ?
 
User avatar
tomaskir
Trainer
Trainer
Posts: 1162
Joined: Sat Sep 24, 2011 2:32 pm
Location: Slovakia

Re: How to send a backup to email

Sat Oct 14, 2017 6:10 pm

You can configure any of them to take a backup every 12h or 24h.

Unimus is the simplest to setup, fastest to use, and has nice things like graphical diff (see changes between backups, or between devices), and a network-wide config search.
(type in "vlan 1002" and see everywhere in your network that is configured)

But it's a commercial product - the other are open source (free).
 
tomislav91
Member
Member
Posts: 303
Joined: Fri May 26, 2017 12:47 pm

Re: How to send a backup to email

Sun Oct 15, 2017 1:59 am

i make virtual linux machine which connect through ssh to router and backup all..:)
 
darkoknght
just joined
Topic Author
Posts: 20
Joined: Fri Oct 06, 2017 5:09 am

Re: How to send a backup to email

Sun Oct 15, 2017 3:40 pm

okay thanks you for the help guys :)
 
User avatar
k6ccc
Forum Guru
Forum Guru
Posts: 1495
Joined: Fri May 13, 2016 12:01 am
Location: Glendora, CA, USA (near Los Angeles)
Contact:

Re: How to send a backup to email

Mon Oct 16, 2017 11:17 pm

and K6ccc do i have to use these 3 scripts ? or the 1st one would do it ?
and where to paste it ? in terminal ?
Sorry for the delay - busy weekend...

You need to run all three. The first one is the script that will create and send the backups. That gets run as often as you want to back up the configs - in my case daily. The second is just your e-Mail setup and you do it only one time. The third sets up a schedule for when the first one should run automatically. That also needs to be run just once.

You can build these from a terminal, WebFig, or WinBox
Sending backups to email is bad for multiple reasons.
Security, scalability, management (imagine you need to change the email address, or email credentials on 100 devices), etc.
Agreed that backing up via E-Mail has some issues. In my case, it's just my two routers at home, and the backups are going through my own mail server, so your three limitations listed are not really much of an issue - at least for me.
 
darkoknght
just joined
Topic Author
Posts: 20
Joined: Fri Oct 06, 2017 5:09 am

Re: How to send a backup to email

Tue Oct 17, 2017 4:02 pm

thank you k6ccc and thaks everybody you are the best :)

Who is online

Users browsing this forum: darkmastor and 33 guests