Syed Jahanzaib Personal Blog to Share Knowledge !

April 25, 2016

Backup your Backup on CLOUD !

Filed under: Linux Related — Syed Jahanzaib / Pinochio~:) @ 11:16 AM

cloudbackup

If you are using command base server operating system with text support only, example ‘Ubuntu Server Edition‘ & if its hosting important application like radius billing, then its best practice to have several layers of backup. One good strategy for multi layer backup should be as following.

  1. Local Backup
  2. USB Backup
  3. CLOUD backup either on remote FTP / Google Drive / Dropbox.
  4. Offline Backup

AND ABOVE ALL, DON’T FORGET, CLUSTER/REPLICATION IS YOUR FRIEND , IT HELPS WHEN YOU ARE IN REAL TROUBLE !  😉 ~ trust me, I am telling your from my personnel experiences   z@!b

https://aacable.wordpress.com/2015/06/26/radius-redundancy-by-using-mysql-master-master-replication/

In this example I am using DROPBOX which is very convenient cloud base backup solution (Free up-to 5 GB, suitable for small size network) and can be installed on your windows / Linux / android as well. So I have Dropbox tool on my windows as well as Linux too. So I just add/remove files at one end, the changes replicate to other end automatically.


TWO STEPS INSTALLATION


1- Create your account at Dropbox, its free

First login to https://www.dropbox.com and register your account.


2- Howto install DROPBOX on UBUNTU 12.4

Quick Notes:

For 32-bit, issue following command …

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86" | tar xzf -

For 64-bit, issue following command:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

Now download the DROPBOX control script

mkdir /temp
cd /temp
wget https://www.dropbox.com/download?dl=packages/dropbox.py
mv download\?dl\=packages%2Fdropbox.py dropbox.py
chmod +x dropbox.py

Now start Dropbox by

/temp/dropbox.py start

It may show you a URL, copy it, and paste in your browser, your Dropbox account will be activated instantly. Something like …

This computer isn’t linked to any Dropbox account…
Please visit https://www.dropbox.com/cli_link_nonce?nonce=e16e663d7e58d959040c83d3ed0f929 to link this device.


  • Now test if Dropbox is started
/temp/dropbox.py status

It should be showing something like

dropbox-status

Now you can upload your files in

/root/Dropbox

Try to make any test file in this folder, and after few moments, check on Dropbox by login to http://www.dropbox.com

results

This is very useful if you want to automate your backup process and have multi layer backup system. You can schedule any cron script that can keep checking for Dropbox status and so on.

If above doesnt works for you, Read following.

http://www.dropboxwiki.com/tips-and-tricks/install-dropbox-in-an-entirely-text-based-linux-environment

Regard's
Syed Jahanzaib !

April 4, 2016

Multiple IF statement matching with Mikrotik Script

Filed under: Mikrotik Related — Tags: , , , — Syed Jahanzaib / Pinochio~:) @ 4:06 PM

mqtching

:if (($dsl1 = "DOWN") && ($dsl2 = "DOWN")) do={

Note: This is a draft version of a solution i made for an OP, donot copy paste, its just showing a different way of achieving the goal by customized scripting in Mikrotik. Surely there are other proper , more sophisticated methods out there, its just a way among them for a lamer like me 😉


 

SCENARIO:

We have two WAN DSL links in our RB with PCC configured. Now 3rd wan link is being attached and it should be used as failover only. Means if both DSL fails, then the master script should disable routing to both dsl, and enable 3rd wan link and send sms as well. In this example we are using VARIABLES from existing scripts and take decision based on those variables.

I used KANNEL as SMS gateway to send sms alerts. [installed on a local linux system]

Script:

WAN1MON = it checks for DSL 1 status and update variable ‘wan1staus’

WAN2MON = it checks for DSL 2 status and update variable ‘wan1staus’

Now we will make 3rd script name MASTER [ described in this post ] which will check for variable values created by above scripts. if it found value DOWN for both wan links, it will simply disable the PCC rules, and will enable simple NAT rule.

I cannot explain the script in details dueto time shortage, but this script was created for some customized purpose and it fulfilled the requirements well , at least for particular OP.



# Mikrotik MASTER WAN Link monitoring SCRIPT with optional SMS Alert,
# We are using local KANNEL as SMS gateway
# by Syed Jahanzaib
# https://aacable.wordpress.com
# Email : aacable at hotmail dot com
# Script Last Modified : 4th-APR-2016 / 1300 hours
# Setting VARIABLES
:local date;
:local time;
:set date [/system clock get date];
:set time [/system clock get time];
:local cell1 "03333021909"

# Company Name, donot use spaces in it
:local COMPANY "JZ"

#If you dont have kannel sms gateway ignore this.
:local KURL "http://192.168.100.1:13013/cgi-bin/sendsms"
:local KID "kannel"
:local KPASS "kannelpass"


:global masterstatus
:local dsl1 [/system script environment get [/system script environment find name="wan1netstatus"] value];
:local dsl2 [/system script environment get [/system script environment find name="WAN2netstatus"] value];

# SMS Msg format for Kannel SMS gateway (donot use spaces in it)
:local MSGDOWNSMS "$COMPANY+WAN+ALERT:%0AWAN1-and-2+is+now+DOWN."

#Match condition
:if (($dsl1 = "DOWN") && ($dsl2 = "DOWN")) do={
:if (($masterstatus="UP")) do={
set masterstatus "DOWN";

# If both vdsl found dead, then enable backup link
:log error "BOTH VDSL SEEMS TO BE DOWN, ACTIVATING BACKUP LB - BACKUP LINK ... Powered by SYED JAHANZAIB"

# Send SMS via KANNEL FOR UP ALERT
/tool fetch url="$KURL\?username=$KID&password=$KPASS&to=$cell2&text=$MSGDOWNSMS"

#INSERT YOUR RULES HERE FOR DOWN ACTION
#/ip firewall mangle disable [find comment="PCC-1"]
#/ip firewall mangle disable [find comment="PCC-2"]
#/ip firewall mangle disable [find comment="PCC-3"]
#/ip firewall mangle disable [find comment="PCC-4"]
#/ip firewall mangle disable [find comment="PCC-5"]
#/ip firewall mangle disable [find comment="PCC-6"]
#/ip firewall nat enable [find comment="BACKUP_NAT_ENABLE_IT_WHEN_VDSL_DOWN"]

# If one or both vdsl seems to be alive, then do nothing, just skip
} else={:set masterstatus "DOWN";}
} else={
:if (($masterstatus="DOWN")) do={
:set masterstatus "UP";
:log warning "At least one or both vdsl seems to be UP... Skipping ... Powered by Syed JahanzaiB"</pre>
#INSERT YOUR RULES HERE FOR UP ACTION
#/ip firewall mangle enable [find comment="PCC-1"]
#/ip firewall mangle enable [find comment="PCC-2"]
#/ip firewall mangle enable [find comment="PCC-3"]
#/ip firewall mangle enable [find comment="PCC-4"]
#/ip firewall mangle enable [find comment="PCC-5"]
#/ip firewall mangle enable [find comment="PCC-6"]
#/ip firewall nat disable [find comment="BACKUP_NAT_ENABLE_IT_WHEN_VDSL_DOWN"]

:local MSGUPSMS "$COMPANY+WAN+INFO:%0AWAN-1-2+have+been+Restored.%0AFailover+Script+Powered+By+Syed+Jahanzaib."

# Send SMS via KANNEL FOR UP ALERT
/tool fetch url="$KURL\?username=$KID&password=$KPASS&to=$cell2&text=$MSGUPSMS"
}
}
} 

Regard’s
Syed Jahanzaib

%d bloggers like this: