You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2.6 KiB

title: ‘mikrotik Backup’

1. Script for DDNS

Create the following script with name TanBack and the following permissions ftp,read,write,policy,test,sensitive

# Tanshu automatic DNS updates
:local date [/system clock get date];
:local day [:pick $date 4 6];
:local month [:pick $date 0 3];
:if ([$month] = "jan") do={ :set month 01 };
:if ([$month] = "feb") do={ :set month 02 };
:if ([$month] = "mar") do={ :set month 03 };
:if ([$month] = "apr") do={ :set month 04 };
:if ([$month] = "may") do={ :set month 05 };
:if ([$month] = "jun") do={ :set month 06 };
:if ([$month] = "jul") do={ :set month 07 };
:if ([$month] = "aug") do={ :set month 08 };
:if ([$month] = "sep") do={ :set month 09 };
:if ([$month] = "oct") do={ :set month 10 };
:if ([$month] = "nov") do={ :set month 11 };
:if ([$month] = "dec") do={ :set month 12 };
:local year [:pick $date 7 11];
:local time [:pick [/system clock get time] 0 5];
:local filename ("Data/10.1.0.x/mikrotik-$year.$month.$day.rsc");
/export file=export.rsc;
/tool fetch src-path=export.rsc user=tanshu mode=ftp password=tan12shu dst-path=($filename) upload=yes;
:log info "TanBack: Backup uploaded with filename $filename"

2. Schedule the script

Create the following schedule with name TanBack-Daily and the following permissions ftp,read,write,policy,test,sensitive, 1 day interval and TanBack On Event.

3. Server preperation

mkdir -p ~/Data/mikrotik-Home

4. Install gdrive

Install gdrive to backup the database to google account in case of data loss at webfaction Go to and download gdrive-linux-x64 in ~/bin/

wget -o ~/bin/gdrive $URL_FOR_GDRIVE_LINUX_X64_BINARY

Make it executable chmod +x ~/bin/gdrive

5. Configure Google Drive

Link your gdrive to the account by running gdrive list and following the instructions.

Create a folder called mikrotik-Home and get its id by running gdrive list.

Create upload script named in the home directory and make it executable chmod +x ~/

#!/usr/bin/env bash
for filename in ~/Data/mikrotik-Home/*.rsc; do
  hash=`sha512sum ${filename} | awk '{ print $1 }'`
  if grep -q "$hash" ~/Data/mikrotik-Home/mikrotik.sha512sums; then
    echo "File $(basename $filename) is uploaded"
    echo "Need to upload $filename"
    sha512sum "$filename" >> ~/Data/mikrotik-Home/mikrotik.sha512sums
    ~/bin/gdrive upload --parent 1eO7hJ6b8_4n43B8GWSVyBtoon4vZyhs6 "$filename"

#### 6. Automate Backups
Edit crontab using `export VISUAL=nano; crontab -e` and add the following line
0 1 * * * ~/