Documentation on ServerBackup
Now On the backupserver machines
mkdir /net/serverbackup ----------> location where all the tar.gz files are stored
This scritpt will wget the flles from vairous server
vi /usr/local/bin/serverbackup
#!/bin/bash
set -x
DIR=/net/serverbackup
SERVERINFO=/net/serverbackup/serverbackupfiles
cd /net/serverbackup
if [ -d $DIR ] ;then
if [ -f $SERVERINFO ];then
for i in `cat $SERVERINFO |awk -F "|" '{print $2}'`
do
`cat $SERVERINFO |grep $i |awk -F "|" '{print $3}'``date +%Y%m%d`.tgz;
done
else
echo " serverbackupfiles does not exist "
fi
else
echo " serverbackup dir does not exist "
fi
This file (serverbackupfiles) is requied by the "serverbackup" script
cat /net/serverbackup/serverbackupfiles
|server112|wget --user=agnello --password=username http:///server112.com/serverbackup/pamserver2.
crontab -e
##for serverbackup to weget the files
0 11 * * * /usr/local/bin/serverbackup
Now On the system to be backed up
cd /net/serverbackup
ln -s /net/serverbackup /var/www/html/serverbackup
vi /usr/local/bin/serverbackupdaily
#!/bin/bash
#
set -x
backupfile1="`date '+%Y%m%d'`"
backupfile="servername.$backupfile1.tgz"
if cd /; then
tar zcf /tmp/$backupfile --exclude-from=/etc/backup/excludedaily `cat /etc/backup/BACKUPDAILY`
mv /tmp/$backupfile /net/serverbackup
chown -R web.web /net/serverbackup
fi
exit 0
vi /etc/httpd/conf/httpd.conf
#setting for serverbackup
AllowOverride AuthConfig
AuthName "serverBackup login"
AuthType Basic
AuthUserFile /net/serverbackup/.htpasswd
AuthGroupFile /dev/null
require user serverbackup
Order deny,allow
Deny from all
Allow from all
htpasswd -bc /net/serverbackup/.htpasswd serverbackup password
crontab -e
##for serverbackup
0 06 * * * /usr/local/bin/serverbackupdaily
script to convert mdir to mbox format
#! /bin/sh
#
# Get a directory name as input and convert all mail files inside
# to mbox format
#
# NOTE: processing of subdirectories not yet implemented correctly:
# all mails in subfolders are put into the same mbox
# (it would be better if an mbox file will be generated for
# each subfolder)
# NOTE: calculation of message date in case of 'From:' doesn't recognise
# time zones
#
# History:
# Feb 06 2001 Joerg Reinhardt
# - first edition
# Feb 07 2001 Joerg Reinhardt
# - added usage output
# Feb 12 2001 Joerg Reinhardt
# - mails not containing a 'From:' field but an 'X-From-Line:' or a
# 'Reply-To:' field are now recognised and also processed (e.g. put into
# the mbox file); this works fine for all my mails
# - added progress information
# - warning about corrupt files is now written to stderr
# check for argument or help argument respectively
if [[ ($1 == "") ||
($1 == "-h") ||
($1 == "--help") ||
($1 == "-help") ]]; then
echo "Usage: "$0" <Xfmail-mail-directory>";
fi;
# check if parameter is a directory
if [[ -d $1 ]]; then
# set target filename
dirname=`echo $1 | awk '{while(substr($0,length($0),1)=="/"){$0=substr($0,1,length($0)-1);}print $0;}'`;
mboxfile=$dirname'.mbox';
# check if directory is empty
if [[ `find $dirname -type f` == "" ]]; then
echo $dirname": directory empty."
exit 1;
fi;
# prevent automatic overwriting of target
if [[ -e $mboxfile ]]; then \
dialogtext="Write file "$mboxfile"?";
if dialog --yesno "$dialogtext" 10 60; then
clear;
rm -vf $mboxfile;
else
clear; exit 1;
fi;
fi;
echo "writing xfmail mail directory '$1' to '$mboxfile'.";
# collect files inside Xfmail mail-directory and produce MBOX format
# target file
for i in `find $1/* -type f`; do
# output progress information
echo -n -e \\r" "
echo -n -e \\rprocessing $i
# look for senders email address in the order
# 'From:'
# 'X-From-Line:'
# 'Reply-To:'
shortfromflag='true';
fromline=`grep 'From:' $i`;
# parse 'From:' field
from=`echo $fromline | awk 'BEGIN{FS="<";}{if($0~/</) {pos=index($2,">");if(pos!=0) {print substr($2,1,pos-1);}} else {pos=index($0,":");print substr($0,pos+1);}}'`;
if [[ $from == "" ]]; then
shortfromflag='false';
fromline=`grep 'X-From-Line:' $i`;
from=`echo $fromline | awk 'BEGIN{FS="Line:";}{print $2;}'`;
if [[ $from == "" ]]; then
shortfromflag='true';
fromline=`grep 'Reply-To:' $i`;
# parse 'Reply-To:' field
from=`echo $fromline | awk 'BEGIN{FS="<";}{if($0~/</) {pos=index($2,">");if(pos!=0) {print substr($2,1,pos-1);}} else {pos=index($0,":");print substr($0,pos+1);}}'`;
if [[ $from == "" ]]; then
echo;
echo "WARNING: "$i": no 'From:' nor 'X-From-Line:' nor 'Reply-To:' field found." >&2;
continue;
fi;
fi;
fi;
if [[ $shortfromflag == "true" ]]; then
# parse date field
dateline=`grep 'Date:' $i`;
if [[ $dateline == "" ]]; then
# set dummy date if no date field found
dateline="Date: Thu, 01 Jan 1970 00:00:00 +0000 (GMT)";
fi;
weekday=`echo $dateline | awk '{gsub(/,/,"",$2);print $2;}'`;
day=`echo $dateline | awk '{print $3;}'`;
month=`echo $dateline | awk '{print $4;}'`;
year=`echo $dateline | awk '{print $5;}'`;
time=`echo $dateline | awk '{print $6;}'`;
diffGMT=`echo $dateline | awk '{print $7;}'`;
timezone=`echo $dateline | awk '{print $8;}'`;
# output MBOX mail header
echo "From " $from $weekday $month $day $time $year >> $mboxfile;
else
# output long MBOX mail header found in 'X-From-Line:' field
echo $from >> $mboxfile;
fi;
# output mail itself
cat $i >> $mboxfile;
done;
echo;
else
echo $1": not a directory.";
fi;
..mumbai's saddest moments ... .our cry for CHANGE
[ This article is the only article in my blog that is non technical, but some thing my heart jsut speaks out toady ]
The last two days has been the caziest in Mumbai and for the people in Mumbai ..I would like to share with you my experience for the last two day that has shook the city . The two days ( Wednesday and Thursday ) mumbia .. especially south Mumbai has seen dramatic seens from the Taj and Oberois hotels . We have lost few of our finest police force and this makes me even more angry to the core . Wednesday night as the terrorist took over the taj, we ( my mom and i ) were watching every glimpse of it on televisions ( thanks to NDTV ) till 2 am .... the visuals that we were coming across were crazy.... looked like a mini Kashmir attack ..... The next day ( Thursday ) was declared a holiday for my company and i guess most companies .... the whole day was spent glued a the visuals in the news ..
One thing i kept hearing on TV was that Mumbaikars will come back strong ..... but this statement is what we have always been saying after every such attack against the city . Mumbai is in need of change . Yes, Mumbai ( Navi -Mumbai ) is a fast pace metropolitan city ... but we tend to forget the such incident too quickly, .... it start with a major media hype through the news networks ... but as the days and weeks pass by people ...our leaders ...people in political power tend to forget .... this aggravates me even more with deeper anger within me .
Just today was i was going in my office ... i was stoped by some security guards at my office building to check my baggage ... they just opened one compartment of my baggage and left it there, ignoring to check the rest of my bag .... this is just an example of how things are going to be like in the next few weeks ....and then slowly fade away. Some times I am so ashamed at the structure and system that are in place in our city. According to the new reports .... the city is not even equipped to with proper fire brigades to pump water to reach the 6th floor of a building, with such loose system in place we can jsut imagine where i our city is heading ... security in our transports system ... especially the local trains, that i personally travel to work, where people have to squeeze and get crushed every morning just to reach their work place . We don't have the slightest security system in place , Yes we do have some few cops around the place ..but that's not going to stop any terrorist from planting a boom somewhere , We need structure and system and really concerned politicians to curb such a future attack on our city . and our Government and local political leaders need to hear our cry ... Yes the city is crying for CHANGE and today its cry ( our cry ) is the loudest ... but what a shame it has to be at the cost of 160 plus lives .
I pray today for the the brave hearts that have laid down their lives for others, and i pray for the victims and the relatives of the victims .... i know what it feels in loosing some one close . as i lost my dad this year in the mouth of January. I pray for our city and for the political leaders that they will bring about the change that is so desperately required .
Thank you for taking time out to read this article , i had tears in my eyes as i was watching few stories on the news from relatives of the victims, in this world that is so unpredictable ... hear today gone tomorrow.
Thank you !
Pen - smtp load balancer
This is pen, a load balancer for "simple" tcp based protocols such as http or smtp. It allows several servers to appear as one to the outside and automatically detects servers that are down and distributes clients among the available servers. This gives high availability and scalable performance.
In this senaerio we have two server ( server A and server B )
server A = Load balancer with pen installed
eth0 = 192.168.50.156
server B = postfix with two instances of psotfix installed ( http://advosys.ca/papers/postfix-instance.html )
eth0 = 192.168.50.124
eth0:1 = 192.168.50.125
postfix should be listening
[root@smtptestserver ~]# netstat -tupln |grep 25
tcp 0 0 192.168.50.125:25 0.0.0.0:* LISTEN 12077/master
tcp 0 0 192.168.50.124:25 0.0.0.0:* LISTEN 11910/master on both server
Installation of Pen on Server A
Downlaod the rpm from here
ftp://194.199.20.114/linux/dag/redhat/el5/en/i386/dag/RPMS/pen-0.17.2-1.el5.rf.i386.rpm
rpm -ivh pen-0.17.2-1.el5.rf.i386.rpm
This should install /usr/bin/pen
# netstat -tupln |grep pen
tcp 0 0 192.168.50.156:25 0.0.0.0:* LISTEN 14505/pen
Now try
telnet 192.168.50.156 25 from any local system it should take you to either 192.168.50.124 or 192.168.50.124
In this senaerio we have two server ( server A and server B )
server A = Load balancer with pen installed
eth0 = 192.168.50.156
server B = postfix with two instances of psotfix installed ( http://advosys.ca/papers/postfix-instance.html )
eth0 = 192.168.50.124
eth0:1 = 192.168.50.125
postfix should be listening
[root@smtptestserver ~]# netstat -tupln |grep 25
tcp 0 0 192.168.50.125:25 0.0.0.0:* LISTEN 12077/master
tcp 0 0 192.168.50.124:25 0.0.0.0:* LISTEN 11910/master on both server
Installation of Pen on Server A
Downlaod the rpm from here
ftp://194.199.20.114/linux/dag/redhat/el5/en/i386/dag/RPMS/pen-0.17.2-1.el5.rf.i386.rpm
rpm -ivh pen-0.17.2-1.el5.rf.i386.rpm
This should install /usr/bin/pen
now we need to tell pen to listen port 25 for all incomning connections and to distribute those connection to 50 .125 and 50.124
# netstat -tupln |grep pen
tcp 0 0 192.168.50.156:25 0.0.0.0:* LISTEN 14505/pen
Now try
telnet 192.168.50.156 25 from any local system it should take you to either 192.168.50.124 or 192.168.50.124
using Expect for ssh auto-login
#!/bin/bash
> /root/.ssh/known_hosts
echo "Connecting to host"
konsole --new-tab -e \expect -c "set timeout -1;\
spawn ssh 192.168.50.103 -l root ;\
match_max 100000;\
expect *(yes/no)?*;\
send -- yes\r;\
expect *password:*;\
send -- qwerasdf\r;\
interact;"
Subscribe to:
Posts (Atom)