2017 © Pedro Peláez
 

project routerboard-backup

Ultimate backup tool for Mikrotik Routerboard

image

routerboard-backup/routerboard-backup

Ultimate backup tool for Mikrotik Routerboard

  • Wednesday, March 28, 2018
  • by heximcz
  • Repository
  • 9 Watchers
  • 20 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 7 Forks
  • 2 Open issues
  • 18 Versions
  • 0 % Grown

The README.md

Mikrotik Routerboard Backup

Latest Stable Version Latest Unstable Version License, (*1)

Changelog

Read changelog for news., (*2)

Overview

Ultimate backup of your mikrotik routerboard configurations. Backup to local hard drive or backup to GitLab repository., (*3)

Prerequisites

PHP >= 7.4 ( from v1.0.3 ), (*4)

Warning

Private Token support will be removed in GitLab 10.2, from this version please use Personal Access Tokens, (*5)

Features

  • support for gitlab base64 file decode** (from 1.0.1)
  • Full support Gitlab API V4 (from 1.0.0)
  • Support for override default SSH port in the config file. (from v0.9.0)
  • Backup to GitLab repository. (from v0.8.0)
  • Auto generate RSA key if it does not exist.
  • Create a new account for backup on a routerboard with a public key.
  • Get routerboard identity and save IP address along with this one to database.
  • When backing up the routerboard, delete the old backup to create new ones. Only the current backup will remain on the routerboard; it will not fill the disk with the old backup.
  • Create standard .backup and .rsc backup files in the form of a script.
  • Your backups are stored on a local disk to the directories; each have in their name an identity and IP address of the backed-up device.
  • Your backups on the local disk are automatically replaced with the current backup. Only the last five backups remain. You will never have a full disk, even after many years to come.
  • If an error occurs while backing up, an email will be sent automatically.
  • Do not forget set up "sendmail_path" value in php.ini ;-)
  • for example sendmail_path = "/usr/sbin/sendmail -t -i -f no-reply@your-domain.com"

How to install

  • Connet via SSH to your web server
$ cd /opt/
$ git clone https://github.com/heximcz/routerboard-backup.git
$ cd /opt/routerboard-backup/
$ git tag -l
$ git checkout tags/<last tag name of stable version>
$ cp ./config.default.yml ./config.yml
$ mkdir -p /var/log/routerboard-backup/
  • !! Do not forget to configure the config.yml !!

Create database


CREATE TABLE IF NOT EXISTS `routers` ( `id` int(11) NOT NULL, `addr` varchar(255) COLLATE utf8_bin NOT NULL COMMENT 'IP address', `port` smallint(5) UNSIGNED DEFAULT NULL, `identity` varchar(255) COLLATE utf8_bin DEFAULT NULL COMMENT 'System identity', `created` datetime NOT NULL, `modify` datetime DEFAULT NULL, `lastbackup` datetime DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; ALTER TABLE `routers` ADD PRIMARY KEY (`id`); ALTER TABLE `routers` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT;

How to update Routerboard Backup

$ cd /opt/routerboard-backup/
$ git pull
$ git tag -l
$ git checkout tags/<last tag name of stable version>
 ```
 - How simply find out how to check the tag

```sh
$ git describe --tags

Example Usage

print help:, (*6)

php ./routerboard-backup.php, (*7)

php ./routerboard-backup.php rb:mod -h, (*8)

php ./routerboard-backup.php rb:backup -h, (*9)

php ./routerboard-backup.php rb:list -h, (*10)

php ./routerboard-backup.php rb:gitlab -h, (*11)

php ./routerboard-backup.php rb:decode -h, (*12)

Using via crontab

add this line to your /etc/crontab: (backup of all in database one per week to local hard drive), (*13)

nano /etc/crontab, (*14)

0 0 * * 6 root /usr/bin/php /opt/routerboard-backup/routerboard-backup.php rb:backup >> /var/log/routerboard-backup/routerboard-backup.log, (*15)

add this line to your /etc/crontab: (backup of all in database one per week to GitLab repository), (*16)

0 0 * * 6 root /usr/bin/php /opt/routerboard-backup/routerboard-backup.php rb:gitlab >> /var/log/routerboard-backup/routerboard-backup.log, (*17)

Logrotate script

nano /etc/logrotate.d/routerboard-backup, (*18)

/var/log/routerboard-backup/*.log
{
    rotate 5
    monthly
    compress
    missingok
    notifempty
}

If this repo helped you set donating to the author of the program., (*19)

Bitcoin: 17MPKzx9jxssa5z83FBPmpfLYTpAcEEfLV

YouTube video: How to

Routerboard Backup Video How To, (*20)

Product site

https://routerboard-backup.best-hosting.cz/, (*21)

License

MIT, (*22)

The Versions