mirror of
https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update.git
synced 2025-08-19 00:39:34 +02:00
Compare commits
No commits in common. "master" and "22.11.12" have entirely different histories.
5 changed files with 396 additions and 667 deletions
|
@ -13,7 +13,7 @@ insert_final_newline = true
|
||||||
|
|
||||||
[*.rsc]
|
[*.rsc]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
indent_size = 2
|
indent_size = 4
|
||||||
|
|
||||||
[*.{yml,yaml,sls}]
|
[*.{yml,yaml,sls}]
|
||||||
indent_style = space
|
indent_style = space
|
||||||
|
|
4
.github/FUNDING.yml
vendored
4
.github/FUNDING.yml
vendored
|
@ -1,4 +1,2 @@
|
||||||
# These are supported funding model platforms
|
# These are supported funding model platforms
|
||||||
ko_fi: beeyev
|
custom: https://buymeacoffee.com/beeyev
|
||||||
liberapay: beeyev
|
|
||||||
buy_me_a_coffee: beeyev
|
|
||||||
|
|
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -1,3 +1 @@
|
||||||
ignore/
|
/ignore
|
||||||
.idea/
|
|
||||||
.vscode/
|
|
File diff suppressed because it is too large
Load diff
60
README.md
60
README.md
|
@ -1,42 +1,45 @@
|
||||||
# Mikrotik RouterOS automatic backup and update
|
# Mikrotik RouterOS automatic backup and update
|
||||||
|
|
||||||
This script allows you to generate daily backups of MikroTik and send them to an email address. You can also choose to enable automatic RouterOS upgrades or receive notifications exclusively for new firmware versions.
|
This script provides an ability to create Mikrotik's daily backups to email. You can also enable automatic RouterOS upgrade or leave only notifications about new firmware versions.
|
||||||
|
|
||||||
|
|
||||||
> 💡 If you have any ideas about the script or you just want to share your opinion, you are welcome to [Discussions](https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update/discussions), or you can open an [issue](https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update/issues) if you found a bug.
|
> 💡 If you have any ideas about the script or you just want to share your opinion, you are welcome to [Discussions](https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update/discussions), or you can open an [issue](https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update/issues) if you found a bug.
|
||||||
|
|
||||||
|
|
||||||
## Features:
|
## Features:
|
||||||
- Select the script's operational mode according to your specific needs (details provided below).
|
- Ability to choose script operating mode according to your needs. *(Read below)*
|
||||||
- This script is designed to create full system backups and export configurations.
|
- Script creates backups of the whole system and exported config.
|
||||||
- Customize the update channel according to your preference.
|
- You can set a preferred update channel.
|
||||||
- With automatic updates activated, the script can be set to apply only patch updates for RouterOS. For instance, should the current RouterOS version be v6.43.6, the script will autonomously upgrade to v6.43.7 (a patch update), while avoiding v6.44.0 (a minor update).*
|
- If automatic updates are enabled, you can set script to install only patch versions of RouterOS updates. *This means if the current RouterOS version is v6.43.6, the script will automatically install v6.43.7 (new patch version) but not v6.44.0 (new minor version), for example.*
|
||||||
- The script also incorporates vital device details in the email alerts, facilitating easy identification of the necessary backup among several devices.
|
- Script includes primary information about the device into the email message. So you can easily find the backup you need among multiple devices.
|
||||||
- For added security, the script is programmed to stop the automatic update process if it fails to dispatch backups via email.
|
- For safety purposes, an automatic update process will not be started if script could not send backups to email.
|
||||||
- Routerboard firmware can be upgraded automatically based on the installed RouterOS version.
|
- Routerboard firmware can be automatically upgraded according to the installed RouterOS version.
|
||||||
|
|
||||||
|
|
||||||
## Script operating modes:
|
## Script operating modes:
|
||||||
**Backups only** - The script generates system and configuration backups and forwards them to a specified email as attachments. It uses your email account as a storage for these backups.
|
**Backups only** - script creates system and config backups and sends them to specified email as an attachment. Using email account as storage for your backups.
|
||||||
**Backups and notifications about new RouterOS release** - In addition to creating backups, the script also monitors for any new releases of RouterOS firmware and communicates this information via email.
|
**Backups and notifications about new RouterOS release** - Except backups, script also checks for new RouterOS firmware release and provides this information in the email.
|
||||||
**Backups and automatic RouterOS upgrade** - The script begins by creating a backup, followed by a check for any new versions of RouterOS. If a newer firmware version is detected, the script initiates the upgrade process. Upon completion, two emails are sent: the first includes the system backups from the prior RouterOS version, and the second, sent post-upgrade, contains backups of the updated system.
|
**Backups and automatic RouterOS upgrade** - Script makes a backup, then checks for new RouterOS version, and if new firmware released, script will initiate upgrade process. By the end, you receive two emails. The first one contains system backups of the previous RouterOS version, the second message will be sent when the upgrade process is done (including backups of the updated system).
|
||||||
|
|
||||||
## How to use
|
## How to use
|
||||||
> ❗️ **Important**
|
> ❗️ **Important**
|
||||||
> Ensure your device identity does not contain spaces and special characters! `System -> Identity`
|
> Make sure that your device identity does not contain any spaces or specific symbols! `System -> Identity`
|
||||||
|
|
||||||
##### 1. Configure parameters
|
##### 1. Configure parameters
|
||||||
Take the [script](https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update/raw/master/BackupAndUpdate.rsc) and configure it's parameters at the beginning of the file.
|
Take the [script](https://github.com/beeyev/Mikrotik-RouterOS-automatic-backup-and-update/raw/master/BackupAndUpdate.rsc) and configure it's parameters at the begining of the file.
|
||||||
This step is straightforward as all parameters are well-commented.
|
This is not difficult because all parameters are well commented.
|
||||||
**Important!** Don't forget to provide correct email address for backups and pay attention to `scriptMode` variable.
|
**Important!** Don't forget to provide correct email address for backups and pay attention a `scriptMode` variable.
|
||||||
|
|
||||||
##### 2. Create new script
|
##### 2. Create new script
|
||||||
System -> Scripts [Add]
|
System -> Scripts [Add]
|
||||||
|
|
||||||
**Important!** Script name must be `BackupAndUpdate`
|
**Important!** Script name has to be `BackupAndUpdate`
|
||||||
Insert the script which you configured earlier into the source area.
|
Put the script which you configured earlier into the source area.
|
||||||

|

|
||||||
|
|
||||||
##### 3. Configure mail server
|
##### 3. Configure mail server
|
||||||
Tools -> Email
|
Tools -> Email
|
||||||
Configure your email server parameters. If you don't have one, i recommend using the [smtp2go.com](https://smtp2go.com "smtp2go.com") service, which allows sending a thousand emails per month for free.
|
Set your email server parameters. If you don't have one, i recommend to use [smtp2go.com](https://smtp2go.com "smtp2go.com") service, it allows sending a thousand emails per month for free.
|
||||||

|

|
||||||
|
|
||||||
To check email settings, send a test message by running the following command in terminal:
|
To check email settings, send a test message by running the following command in terminal:
|
||||||
|
@ -47,7 +50,7 @@ To check email settings, send a test message by running the following command in
|
||||||
##### 4. Create scheduled task
|
##### 4. Create scheduled task
|
||||||
System -> Scheduler [Add]
|
System -> Scheduler [Add]
|
||||||
Name: `Backup And Update`
|
Name: `Backup And Update`
|
||||||
Start Time: `03:10:00` (the start time has to be different for all your mikrotik devices in a chain)
|
Start Time: `03:10:00` (the start time has to be different for all your mikrotik device in a chain)
|
||||||
Interval: `1d 00:00:00`
|
Interval: `1d 00:00:00`
|
||||||
On Event: `/system script run BackupAndUpdate;`
|
On Event: `/system script run BackupAndUpdate;`
|
||||||

|

|
||||||
|
@ -57,27 +60,20 @@ Or you can use this command to create the task:
|
||||||
/system scheduler add name="Firmware Updater" on-event="/system script run BackupAndUpdate;" start-time=03:10:00 interval=1d comment="" disabled=no
|
/system scheduler add name="Firmware Updater" on-event="/system script run BackupAndUpdate;" start-time=03:10:00 interval=1d comment="" disabled=no
|
||||||
```
|
```
|
||||||
##### 5. Test the script
|
##### 5. Test the script
|
||||||
Once everything is set up, it's important to verify that the script is functioning properly.
|
When everything is done, you need to make sure that the script is working correctly.
|
||||||
To do this, open a New Terminal and a Log window in your WinBox, then manually execute the script by typing `/system script run BackupAndUpdate;` in the Terminal.
|
To do so, open a New Terminal and Log window in your WinBox, then run the script manually by executing this command `/system script run BackupAndUpdate;` in Terminal.
|
||||||
You will see the script the script's operation in the log window. If the script completes without any errors, check your email. You'll find a new message with backups from your MikroTik awaiting you. 🎉
|
You will see the script working process in the log window. If the script finished without errors, check your email, there is a fresh message with backups from your MikroTik waiting for you 🎉
|
||||||
|
|
||||||
|
## Contributors
|
||||||
|
|
||||||
|
- [DJ5KP](mailto:dj5kp@dj5kp.de), website: [dj5kp.de](http://dj5kp.de/)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Acknowledgements
|
|
||||||
I would like to extend my sincere gratitude to the following individuals who have contributed to this project:
|
|
||||||
- DJ5KP, website: [dj5kp.de](http://dj5kp.de/)
|
|
||||||
|
|
||||||
Special thanks to the talented people who are working at [MikroTik](https://mikrotik.com) for their contributions in creating such outstanding products.
|
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
The MIT License (MIT). Please see [License File](LICENSE.md) for more information.
|
||||||
|
|
||||||
---
|
---
|
||||||
If you love this project, please buy more mikrotiks ;) and consider giving me a ⭐
|
If you love this project, please consider giving me a ⭐
|
||||||
|
|
||||||
[__Buy me a coffee! :coffee:__](https://www.buymeacoffee.com/beeyev)
|
[__Buy me a coffee! :coffee:__](https://www.buymeacoffee.com/beeyev)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue