List of scripts

Examples of scripts usage

func_getlastbackup (by id) – get last backup basing on id
func_getlastbackup (by creation time) – get last backup basing on creation time property
func_cmp2dates – compare dates in format “jan/01/1970”
func_date2int – convert date in format “jan/01/1970” to int to allow dates comparing
func_time2int – convert time in format “HH:MM:SS: to seconds to allow time comparing
func_datetime2str – get date/time in “YYYY-MM-DD_HHMMSS” format


Step 1. Generate backup
Step 2. Try send via Mail
Step 3. Try send via FTP
Step 4. Create backups log and send it via Mail

Full backup script v1.4 (not sends backups via mail)

Dates manipulation module

func_datetime2str – generates string from date and time
func_cmp2dates – compare two dates
func_daysInMonth – get days in the month
func_daysInYear – get days in the year
func_shiftDate – add/sub days to given date
func_subDates – count days between two given days
func_date2days – count days from base (01/01/1970 by default) to given date
test_dates – script to test all dates manipulation functions. Can be used as example for importing functions to your code.

Full script is here – dates-v1.1.rsc

Module discussion is here .

Mikrotik and Telegram

func_fetch – wrapper for /tool fetch
tg_config – config
tg_getUpdates – check Telegram for updates and run command scripts
tg_sendMessage – send message to Telegram
tg_cmd_hi – example of /hi command
tg_cmd_health – example of /health command

Full script – telegram_v1

Discussion is here

Multi-VPN switcher

Full script – VPN_switcher_v1.0

1. Import and set/tune parameters in vpn-tunnel-check and vpn-interfaces scripts:

vpn-tunnel-check :

gw – what to ping
cnt2ping – how much too ping
minlevel – minimum allowed successful ping to count channel alive


imask – mask for switched channels. For example “^VPN*” means channels, starting from “VPN” in their name.
delayBeforeChecks – delay between enabling of channel and starting it’s health check.

checkIfRunning – will we check “running” status. Makes sense for pptp/l2tp.
runningDelay – delays between “running” checks
runningMaxCount – how long we will wait for “running”=true

checkIfPing – will we check health of channel by pinging.
checkPing2Interface – will we specify interface during ping. I.e. will we ping via concrete interface.
ping2host – host to be pinged
pingMaxCount – how much to ping
pingMinCount – minimal successful pings to count channel alive

2. Check scripts vpn-tunnel-check and vpn-interfaces by running them from terminal.

3. Enable vpn-check-task scheduler task.

Discussion is here