BackupROS (Centralized Backups) - by Nahuel Ramos
From MikroTik Wiki
Contents |
BackupROS version 0.1
Hi, I want to share with you some scripts I have made which let you manage your RouterOS's backups files in a centralized storage with the addon of send mail with an attached archived of files.
This tool helps you keeping organize your files in diferente folders/directories and gives you the option to keep or delete .backup files from RouterOS.
Requirement
There is only one requeriment, to have a PC running Linux or Windows with JVM installed.
Howto
Notice: this tool was made to be used with RouterOS v5 but some tuning will make us be able to using it with version 4.
So, lets start with install instructions:
1. Download and extract file where you want to keep RouterOS's backups files: BackupROS_0.1.zip (link to SourceForge.net project)
2. For each ROS you want to add you have to:
Enable SSH and FTP services
/ip service set ftp address=0.0.0.0/0 disabled=no port=21 set ssh address=0.0.0.0/0 disabled=no port=22
Create one user with SSH and FTP access
/user add address=<YOUR_PC_IP_ADDRESS> comment="" disabled=no group=full name=<USERNAME>
Important: please note that FTP protocol send user and password in plain text so filter the access of the user to an specific host.
3. Create your backupROS.conf under path "/path/to/BackupROS_0.1/BackupROS" directory (use files "backupROS.conf.demo" and "backupROS.conf.explained" to guide you)
4. If you are using RouterOS v5 thats all (ENJOY IT!!), if not please check "RouterOS v4 tuning to use BackupROS v0.1" section.
RouterOS v4 tuning to use BackupROS v0.1
ROS v5 and ROS v4 have different SSH protocol version. I was not be able to connect to ROS v4 and create the backup file with an SSH command, so you have schedule a backup script to build the file. Here are the commands you need to add in ROS v4:
Script to make a backup file with filename like "INDENTIFY-YYYYMMMDD.backup"
/system script
add name=backup policy=\
ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source="/\
system backup save name=([/system identity get name] . \"-\" . [:pick [/sys\
tem clock get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [\
/system clock get date] 4 6]);"
Schedule the script to execute with an interval of 3 days (change your periodicity as you prefer)
/system scheduler
add comment="" disabled=no interval=3d name=backup_sched on-event=backup \
policy=read,write start-date=jan/01/1970 start-time=01:00:00
Configuration file backupROS.conf
There is only one configuration file that permits you add new RouterOS devices to the BackupROS in seconds. Without need to restart the service. The path for the configuration file is /path/to/BackupROS_0.1/BackupROS and here is the structure of the backupROS.conf file:
backupROS.conf Structure:
SMTP_ADDRESS|SMTP_PORT|FROM_ADDRESS|TO_ADDRESS|SMTP_USER|SMTP_PASSWORD ROUTEROS_IP1|USER1|PASSWORD1|SSH_PORT1|DELETE_FILE_FROM_ROS|SEND_MAIL_WITH_BACKUP ROUTEROS_IP2|USER2|PASSWORD2|SSH_PORT2|DELETE_FILE_FROM_ROS|SEND_MAIL_WITH_BACKUP ROUTEROS_IP3|USER3|PASSWORD3|SSH_PORT3|DELETE_FILE_FROM_ROS|SEND_MAIL_WITH_BACKUP ... ROUTEROS_IPN|USERN|PASSWORDN|SSH_PORTN|DELETE_FILE_FROM_ROS|SEND_MAIL_WITH_BACKUP
backupROS.conf Demo:
smtp.gmail.com|465|myaccount@gmail.com|me@enterprise.com|myaccount@gmail.com|mygmailpassword 10.200.30.140|user1|p4s5w0rd|22|no|no 94.251.124.31|john|MyPaSS|1022|yes|yes 172.30.1.2|nahuel|RaMos|10022|no|yes
Running BackupROS
Note that you have two running shell/batch files in folder/directory /path/to/BackupROS_0.1/BackupROS. You could run the tool on Linux y Windows. Also you could use crond (Linux) or programmed task (Windows) to run automatically and periodicaly.
On Linux you have to run:
/path/to/BackupROS_0.1/BackupROS/BackupROS_run.sh
On Windows you have to run :
C:\Path\To\BackupROS_0.1\BackupROS\BackupROS_run.bat
Conclusion
This is the first release of BackupROS, please be patient if something goes wrong. This software is free and using it is YOUR RESPOSIBILITY. Please report bugs and suggestions at BackupROS project site.
