Initial Commit. First Release

This commit is contained in:
Grzegorz Budny 2019-10-14 20:53:37 +02:00
parent 69ab2f58ca
commit a9d2fcc235
4 changed files with 91 additions and 2 deletions

22
RouterOS_Cloud_Backup.rsc Normal file
View file

@ -0,0 +1,22 @@
# RouterOS Function
# Copyright (c) Grzegorz Budny
# Create new backup file and uploads it to cloud
:global CloudBackup do={
:local systemLicense [/system license get value-name=level];
:local systemName [/system identity get name];
:if ($currentLicenseLevel != "free") do={
:log info "...:::License allows cloud backup, process started:::..."
/system backup cloud upload-file action=create-and-upload file=cloudBackup.backup password=password
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
to=$recipient subject=($systemName." cloud backup created.") body=($systemName." created MikroTik cloud backup.");
:log info "...:::Cloud Backup Created:::...";
}
}

View file

@ -1,2 +1,28 @@
:global n [file get value-name=name number=2]
:if ($n ~ ".txt") do={/file remove $n} else={:put "No"}
# RouterOS Function
# Copyright (c) Grzegorz Budny
# Removes files by specific name or file extansion
:global FileScreening do={
:local systemName [/system identity get name];
:local filesNumber [/file print count-only];
:local fileName;
:for i from=0 to=$filesNumber step=1 do= \
{
:set fileName [/file get value-name=name number=$i];
:if ($fileName ~ $keyWord) do={
/file remove $fileName;
:log warning ("...:::".$fileName." removed. Matched ".$keyWord.":::...");
:set fileName;
}
}
}
$FileScreening keyWord=".txt";

26
RouterOS_Mail_Backup.rsc Normal file
View file

@ -0,0 +1,26 @@
# RouterOS Function
# Copyright (c) Grzegorz Budny
# Creates backup and config file and sends them via email
:global MailBackup do={
:local systemName [/system identity get name];
:log info "...:::Mail backup started:::...";
/export file=$configName;
/system backup save name=$backupName;
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
to=$recipient subject=($systemName." mail config backup") body="Enclosed backup files" \
file=$configName;
/tool e-mail send server=$smtpServer port=$smtpPort from=($systemName.$domain) \
to=$recipient subject=($systemName." mail backup") body="Enclosed backup files" \
file=$backupName;
:log info ("...:::Backup files sent to".$recipient.":::...");
}
$MailBackup configName=configName backupName=backupName smtpServer=smtpServer smtpPort=smtpPort domain=@example.com \
recipient=recipient@example.com;

View file

@ -0,0 +1,15 @@
# RouterOS Script
# Copyright (c) Grzegorz Budny
# Renews RouterOS License
:global RenewLicense do={
:local currentLicenseLevel [/system license get value-name=level];
:if ($currentLicenseLevel = "free") do={
/system license renew account=$account password=$password level=$level;
:log info ("Renewing license for ".$account." to ".$level);
}
}