Community discussions

 
NetWorker
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 61
Joined: Sun Jan 31, 2010 6:55 pm

Backup script

Wed May 15, 2019 10:38 pm

Hi everyone,

a couple of weeks ago I became aware that years of routerOS backups all nice and tidily organized in one of our backup servers are USESLESS if an older router goes belly up. Read all about it here.

Long story short, in case you're blissfully unaware like I was that using the winbox backup function gives you a file that you can't use in a different router I suggest you start implementing a script that gives you both the export and backup pronto!

Here's mine if you don't feel like writing from scratch:
# Backup script.
#
# This script exports the compact configuration and then a full system backup to file.
# Both files will be created using system name and date.
# You may want to encrypt your backup file. Edit below with dontencrypt=yes encryption=aes-sha256
# and password=whatever
# Run it however you like (scheduler, manually, other scripts) and e-mail or download the files.
# As always, bugs, complaints, suggestions, free beer, all welcome.
# Regards, Networker

:local filename ([/system identity get name] . "." . [:pick [/system clock get date] 0 3] \
. "." . [:pick [/system clock get date] 4 6] . "." . [:pick [/system clock get date] 7 11]);


:export compact file=$filename;

/system backup save name=$filename dont-encrypt=yes
 
NetWorker
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 61
Joined: Sun Jan 31, 2010 6:55 pm

Re: Backup script

Wed May 15, 2019 10:41 pm

Oh and in case anyone's wondering about all the picks, the system date comes back with / (slashes) which you can't use in a filename so I replace those with . (dots).
 
Madnessy
just joined
Posts: 3
Joined: Wed May 15, 2019 9:44 pm

Re: Backup script

Wed May 15, 2019 10:49 pm

well what use is the build-in scripting and a linux box that pulls the backup from the router and stores it on a nas.
quick & dirty solution , but this allows me to make a backup for example from a rb2011 and restore it on a hapac2
 
NetWorker
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 61
Joined: Sun Jan 31, 2010 6:55 pm

Re: Backup script

Mon May 20, 2019 3:24 am

well what use is the build-in scripting and a linux box that pulls the backup from the router and stores it on a nas.
quick & dirty solution , but this allows me to make a backup for example from a rb2011 and restore it on a hapac2
Exactly!
 
User avatar
Jotne
Forum Guru
Forum Guru
Posts: 1126
Joined: Sat Dec 24, 2016 11:17 am
Location: Magrathean

Re: Backup script

Mon May 20, 2019 1:31 pm

I do use export as a normal backup since I can read the file, and adopt it to a new router if needed.
The backup function is more used for testing purpose. Having several version of a config.
 
How to use Splunk to monitor your MikroTik Router

MikroTik->Splunk
 
 
NetWorker
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 61
Joined: Sun Jan 31, 2010 6:55 pm

Re: Backup script

Mon May 20, 2019 4:31 pm

Agreed. Though it did save me twice on a rb2011 that went into a boot loop. Reinstalling routerOS over serial and then restoring the backup file was easier than having to import all the certificates and a few other things that are not in the compact again. It's not that you can't do it but it does save time.

Who is online

Users browsing this forum: No registered users and 6 guests