Archive for category Scripts

We Wish You A Merry Relay?


Maybe this is how Santa delivers his spam?

[root@mail ~]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 14605 3050 1380 2446 7688 41 0 0 0 0 0

yahoo.com.tw 12065 2556 1156 1997 6321 35 0 0 0 0 0

msa.hinet.net 441 89 46 74 231 1 0 0 0 0 0

gmail.com 368 72 30 64 201 1 0 0 0 0 0

schofieldcare.org 137 8 3 11 115 0 0 0 0 0 0

xuite.net 54 16 4 10 24 0 0 0 0 0 0

pchome.com.tw 40 8 5 8 19 0 0 0 0 0 0

kimo.com 39 7 4 11 17 0 0 0 0 0 0

ms23.hinet.net 39 10 1 10 17 1 0 0 0 0 0

 

[root@mail log]# grep sasl_username=test maillog|wc -l

34734 <———————————————————- Number of email sent from the “test” account

[root@mail log]# grep C54715B8472 maillog | grep message-id|more

Dec 21 01:01:12 mail postfix/cleanup[31360]: C54715B8472: message-id=<a5c298c7fad7435bbdd26cf3efd937aa@263703c3aa76423dbdd91eb6ede2d4fd>

[root@mail log]# grep a5c298c7fad7435bbdd26cf3efd937aa@263703c3aa76423dbdd91eb6ede2d4fd maillog | grep cleanup

Dec 21 01:01:12 mail postfix/cleanup[31360]: C54715B8472: message-id=<a5c298c7fad7435bbdd26cf3efd937aa@263703c3aa76423dbdd91eb6ede2d4fd>

Dec 21 01:01:12 mail postfix/cleanup[31751]: D74115B8471: message-id=<a5c298c7fad7435bbdd26cf3efd937aa@263703c3aa76423dbdd91eb6ede2d4fd>

Dec 21 01:01:16 mail postfix/cleanup[31892]: 6E5E15B828E: message-id=<a5c298c7fad7435bbdd26cf3efd937aa@263703c3aa76423dbdd91eb6ede2d4fd>

[root@mail log]# grep C54715B8472 maillog

Dec 21 01:01:09 mail postfix/smtpd[29735]: C54715B8472: client=unknown[168.187.87.132], sasl_method=LOGIN, sasl_username=test@schofieldcare.org

Dec 21 01:01:12 mail postfix/cleanup[31360]: C54715B8472: message-id=<a5c298c7fad7435bbdd26cf3efd937aa@263703c3aa76423dbdd91eb6ede2d4fd>

Dec 21 01:01:12 mail postfix/qmgr[23536]: C54715B8472: from=<mykjfx@yahoo.com.tw>, size=2354, nrcpt=11 (queue active)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<ting1019@ms34.hinet.net>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<t8813966@ms35.hinet.net>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<4811216@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<ae0420002000@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<g8322@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<jenny-yin@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<lisa9547343@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<louis79318@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<shinji123456@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<tung6008@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/pipe[31966]: C54715B8472: to=<yl2007606@yahoo.com.tw>, relay=mailprefilter, delay=3, status=sent (mail.schofieldcare.org)

Dec 21 01:01:12 mail postfix/qmgr[23536]: C54715B8472: removed

 

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 23 23 0 0 0 0 0 0 0 0 0

yahoo.com.tw 20 20 0 0 0 0 0 0 0 0 0

ms41.hinet.net 1 1 0 0 0 0 0 0 0 0 0

ms37.hinet.net 1 1 0 0 0 0 0 0 0 0 0

schofieldcare.org 1 1 0 0 0 0 0 0 0 0 0

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 14 14 0 0 0 0 0 0 0 0 0

yahoo.com.tw 11 11 0 0 0 0 0 0 0 0 0

schofieldcare.org 2 2 0 0 0 0 0 0 0 0 0

headwayofwny.org 1 1 0 0 0 0 0 0 0 0 0

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 14 14 0 0 0 0 0 0 0 0 0

yahoo.com.tw 11 11 0 0 0 0 0 0 0 0 0

schofieldcare.org 2 2 0 0 0 0 0 0 0 0 0

headwayofwny.org 1 1 0 0 0 0 0 0 0 0 0

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 4 4 0 0 0 0 0 0 0 0 0

schofieldcare.org 3 3 0 0 0 0 0 0 0 0 0

headwayofwny.org 1 1 0 0 0 0 0 0 0 0 0

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 4 4 0 0 0 0 0 0 0 0 0

schofieldcare.org 4 4 0 0 0 0 0 0 0 0 0

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 2 2 0 0 0 0 0 0 0 0 0

schofieldcare.org 2 2 0 0 0 0 0 0 0 0 0

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 0 0 0 0 0 0 0 0 0 0 0

 

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 0 0 0 0 0 0 0 0 0 0 0

[root@mail log]# mail -s “Test from Scofield SMB” gconklin@proserve-solutions.com

Cc:

Null message body; hope that’s ok

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 3 3 0 0 0 0 0 0 0 0 0

yahoo.com 1 1 0 0 0 0 0 0 0 0 0

schofieldcare.org 1 1 0 0 0 0 0 0 0 0 0

proserve-solutions.com 1 1 0 0 0 0 0 0 0 0 0

[root@mail log]# qshape incoming active deferred

T 5 10 20 40 80 160 320 640 1280 1280+

TOTAL 0 0 0 0 0 0 0 0 0 0 0

[root@mail log]#

Advertisements

, , , , , , , , , ,

Leave a comment

CIFS it is…


This is the final, fully tested and functional remote backup script for linux… Finally ūüôā

#!/bin/bash
# A straght forward system backup script
#
LOGBASE=/var/log/backup/log
BACKUP_ROOT_DIR=”a/facts77 a/can”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Backup dirs; do not prefix /
NOW=$(date +”%a”)¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Get todays day
TSTAMP=$(date +”%l:%M:%S”)¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Get time stamp H:M:S
TDATE=$(date -I)                                        ## Get todays date
TAPE=”/oracle55vm_backup”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Backup device name
TAR_ARGS=””¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Exclude file
EXCLUDE_CONF=/root/.backup.exclude.conf                 ## Named file for file exclusion
LOGFILE=$LOGBASE/$TDATE.backup.log                      ## Backup Log file
FILELIST=$LOGBASE/$TDATE.backup.file-listing.log        ## Backup Log file list
UNAME=”xxx”
PWORD=”xxxXXXX”
SYSTEM=”`uname -n|cut -c 1-10`”
# Path to binaries
TAR=/bin/tar
MKDIR=/bin/mkdir
#
full_backup(){
local old=$(pwd)i
cd /
# Mount the samba destination
mount.cifs //bufvmfacts01/G/oracle55vm_backup $TAPE -o username=$UNAME,password=$PWORD
# Search the directory for files older than 7 days and delete them
find /oracle55vm_backup -type f -mtime +7|xargs -r rm -f
# Run the backup
tar -zcvf $TAPE/$SYSTEM.bak.`date -I`.tgz $BACKUP_ROOT_DIR # gzipping these
cd $old
}
# Make sure all dirs exits
verify_backup_dirs(){
local s=0
for d in $BACKUP_ROOT_DIR
do
if [ ! -d /$d ];
then
echo “Error : /$d directory does not exit!”
s=1
fi
done
# if not; just die
[ $s -eq 1 ] && exit 1
}
# Make some kind of status report
report_backup_info(){
touch $LOGBASE/$TDATE.backup.file-listing.log
cd $TAPE
echo ” ”
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† **** Backup Report ****”
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ****¬†¬† $TDATE¬† ****”
echo ” ——————————————————————————— ”
echo ” ################################################################################# ”
echo ” _________________________________________________________________________________ ”
echo ” ”
echo ” ”
echo ”¬† Backup start time: $TSTAMP”
echo ”¬† Operating System: `cat /etc/redhat-release`”
echo ” ”
echo ”¬† Size of the complete archive: `tar -ztvf $SYSTEM.bak.$TDATE.tgz|wc -c` Bytes”
echo ”¬† Size of the logged archive:¬†¬† `cat $FILELIST|wc -c` Bytes”
echo ” ”
echo ”¬† File count of the completed archive: `tar -ztvf $SYSTEM.bak.$TDATE.tgz|wc -l` Files”
echo ”¬† File count of the logged archive:¬†¬†¬† `cat $FILELIST|wc -l` Files”
echo ” ”
echo ”¬† Remote CIFS Directory Listing:”
ls -lh
echo ” ”
echo ”¬† Disk Summary:”
df -h
echo ” ”
echo ” _________________________________________________________________________________ ”
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ” ################################################################################# ”
echo ” ——————————————————————————— ”
echo ” ”
cd –
} > $LOGFILE 2>&1
#
#
# Clean Up
clean_up(){
cd /
umount $TAPE # unmount the cifs mount
# Email the report
mail -s “System Backup $SYSTEM” gconklin@proserve-solutions.com < $LOGFILE
}
#
#
#### MAIN ####
#
# Make sure log dir exits
[ ! -d $LOGBASE ] && $MKDIR -p $LOGBASE
#
# Verify dirs
verify_backup_dirs
#
#
# Okay let us start backup procedure
# If it is Monday-Friday make a full backup;
# Weekend no backups
full_backup > $FILELIST 2>&1
#
#
# Make the simple report
report_backup_info
#
# Call the Clean UP function
clean_up

, , , , , , , , , , ,

Leave a comment

Backup Takanga‚Ķ RHEL v5.5‚Ķ Dancing with CIFS


OK, so a few days ago I did one of these to backup to an internal tape device… This time it’s going on a remote Windows share through CIFS… It is mostly the same as the tape version… I’m sure you’ll notice the subtleties… I am not much of a report writer so please excuse the ugliness of the info, but this really is primarily to facilitate a backup not report on it…¬† Anyway what I have come up with also uses a nifty find command to manage the remote Windows share in terms of number of backup files… I suggest doing something similar as you will eventually overrun the remote store if you don’t…¬†¬† In any event.. the script below is fully tested and functional… as always ūüôā

#!/bin/bash
# A straght forward system backup script
#
LOGBASE=/var/log/backup/log
BACKUP_ROOT_DIR=”a/facts77 a/can”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Backup dirs; do not prefix /
NOW=$(date +”%a”)¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Get todays day
TSTAMP=$(date +”%l:%M:%S”)¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Get time stamp H:M:S
TDATE=$(date -I)                                        ## Get todays date
TAPE=”/oracle55vm_backup”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Backup device name
TAR_ARGS=””¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Exclude file
EXCLUDE_CONF=/root/.backup.exclude.conf                 ## Named file for file exclusion
LOGFILE=$LOGBASE/$TDATE.backup.log                      ## Backup Log file
FILELIST=$LOGBASE/$TDATE.backup.file-listing.log        ## Backup Log file list
UNAME=”xxx”
PWORD=”xxxXXXX”
SYSTEM=`uname -n|cut -c 1-10`
# Path to binaries
TAR=/bin/tar
MKDIR=/bin/mkdir
#
full_backup(){
local old=$(pwd)i
cd /
# Mount the samba destination
mount.cifs //bufvmfacts01/G/oracle55vm_backup $TAPE -o username=$UNAME,password=$PWORD
# Search the directory for files older than 7 days and delete them
find /oracle55vm_backup -type f -mtime +7|xargs -r rm -f
# Run the backup
tar -zcvf $TAPE/$SYSTEM_backup.`date -I`.tgz $BACKUP_ROOT_DIR # gzipping these
cd $old
}
# Make sure all dirs exits
verify_backup_dirs(){
local s=0
for d in $BACKUP_ROOT_DIR
do
if [ ! -d /$d ];
then
echo “Error : /$d directory does not exit!”
s=1
fi
done
# if not; just die
[ $s -eq 1 ] && exit 1
}
# Make some kind of status report
report_backup_info(){
touch $LOGBASE/$TDATE.backup.file-listing.log
cd $TAPE
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† **** Backup Report ****¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† **** $TDATE ****¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ” ——————————————————————————— ”
echo ” ################################################################################# ”
echo ” ——————————————————————————— ”
echo “|¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† |”
echo ”¬† Backup start time: $TSTAMP¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Operating System: `cat /etc/redhat-release`¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Size of the complete archive: `tar -ztvf $SYSTEM.$TDATE.tgz|wc -c` Bytes¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Size of the logged archive:¬†¬† `cat $FILELIST|wc -c` Bytes¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† File count of the completed archive: `tar -ztvf $SYSTEM.$TDATE.tgz|wc -l` Files¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† File count of the logged archive:¬†¬†¬† `cat $FILELIST|wc -l` Files¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Remote CIFS Directory Listing:¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† ls -l¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Disk Summary:¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† `df -h`¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo “|¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† |”
echo ” ——————————————————————————— ”
echo ” ################################################################################# ”
echo ” ——————————————————————————— ”
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
cd –
} > $LOGFILE 2>&1
#
#
# Clean Up
clean_up(){
cd /
umount $TAPE # unmount the cifs mount
}
#
#
#### MAIN ####
#
# Make sure log dir exits
[ ! -d $LOGBASE ] && $MKDIR -p $LOGBASE
#
# Verify dirs
verify_backup_dirs
#
#
# Okay let us start backup procedure
# If it is Monday-Friday make a full backup;
# Weekend no backups
full_backup > $FILELIST 2>&1
#
#
# Make the simple report
report_backup_info
#
# Call the Clean UP function
clean_up

, , , , , , , , , ,

Leave a comment

Backup Takanga… RHEL v5.5… Sounds like a dance?


Well what a surprise and well kind of an embarrassment I faced the last 2 days…¬† I guess I have gotten pretty lazy these days as I wouldn’t have expected to miss this one, but I did.¬† I was building a new system for a customer upgrade and they selected RHEL v5.5 as the platform… Cool.¬† So as usual I sent in my request to our Dell “Gold_Team” rep with specs of what I wanted for this build.¬† Nothing fancy, a nice PowerEdge T410, dual quadcore procs, 8GB RAM, RAID1 (Perc6i of course) and the infamous RD1000 internal tape drive.¬† Now I posed the question because I am, well lazy, inquiring to include Symantec’s 2010 Backup EXEC application if it in fact runs on a Linux server.¬† Well that’s all it took to screw things up a bit.¬† I guess this can go either way, but what they shipped was the remote Linux agent for Symantec backup EXEC due to the fact (which they failed in let us know) that Backup EXEC does NOT run natively on any Linux platform as a standalone master server.¬† Great… I guess I should have known and shame on me for wanting a commercial app to run on Linux, but hey… I also didn’t know that the tapes for the drive are NTFS formatted by default and of course Linux cannot play with that filesystem formatting, but nothing a little fdisk-ing couldn’t fix… I am waiting for a quote back from Dell on their NetBackup 7.0.1 product (Also from Symantec…LOL)

, but I think it will be overkill to say the least for 1 server.¬† So in the interim, I whipped up a temp fix in the event that we opt for nothing…

Here is what I came up with:

#!/bin/bash
# A straight forward system backup script
#
LOGBASE=/var/log/backup/log
#BACKUP_ROOT_DIR=”a boot var etc”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Backup dirs; do not prefix /
BACKUP_ROOT_DIR=”a”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Backup dirs; do not prefix /
NOW=$(date +”%a”)¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Get todays day
TSTAMP=$(date +”%l:%M:%S”)¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Get time stamp H:M:S
TDATE=$(date -I)                                        ## Get todays date
TAPE=”/dev/sdb1″¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Backup device name
TAR_ARGS=””¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ## Exclude file
EXCLUDE_CONF=/root/.backup.exclude.conf                 ## Named file for file exclusion
LOGFILE=$LOGBASE/$TDATE.backup.log                      ## Backup Log file
FILELIST=$LOGBASE/$TDATE.backup.file-listing.log        ## Backup Log file list
# Path to binaries
TAR=/bin/tar
MKDIR=/bin/mkdir
#
full_backup(){
local old=$(pwd)
cd /
$TAR $TAR_ARGS -cvpf $TAPE $BACKUP_ROOT_DIR
cd $old
}
# Make sure all dirs exits
verify_backup_dirs(){
local s=0
for d in $BACKUP_ROOT_DIR
do
if [ ! -d /$d ];
then
echo “Error : /$d directory does not exit!”
s=1
fi
done
# if not; just die
[ $s -eq 1 ] && exit 1
}
# Make some kind of status report
report_backup_info(){
touch $LOGBASE/$TDATE.backup.file-listing.log
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ” ————————————————————————- ”
echo “|¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† |”
echo ”¬† Backup start time: $TSTAMP¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Operating System: `cat /etc/redhat-release`¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Size of the complete archive: `tar -tvf /dev/sdb1|wc -c` Bytes¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† Size of the logged archive: `cat $FILELIST|wc -c` Bytes¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo ”¬† File count of the completed archive: `tar -tvf /dev/sdb1|wc -l` Files¬†¬†¬† ”
echo ”¬† File count of the logged archive: `cat $FILELIST|wc -l` Files¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
echo “|¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† |”
echo ” ————————————————————————- ”
echo ”¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ”
} > $LOGFILE 2>&1
#
#### MAIN ####
#
# Make sure log dir exits
[ ! -d $LOGBASE ] && $MKDIR -p $LOGBASE
#
# Verify dirs
verify_backup_dirs
#
#
# Okay let us start backup procedure
# If it is Monday-Friday make a full backup;
# Weekend no backups
case $NOW in
Mon|Tue|Wed|Thu|Fri)    full_backup;;
*) ;;
esac > $FILELIST 2>&1
# make the simple report
report_backup_info

Ahhh… The “Ghetto-scripts” live on… ūüôā

This is the output that I guess I could send in an email blast:

————————————————————————-
|                                                                                                                       |
Backup start time:  9:27:36
Operating System: Red Hat Enterprise Linux Server release 5.5 (Tikanga)
Size of the complete archive: 4295 Bytes
Size of the logged archive: 4295 Bytes
File count of the completed archive: 93 Files
File count of the logged archive: 93 Files
|                                                                                                                       |
————————————————————————-

, , , , , , , , ,

2 Comments

SOFTware-pantyRAID


OK… so I completed a build yesterday and of course being the great engineer that I am (LOL), I didn’t add the final disk set to the vm for the bulk of the filesystem to be used for the native application.¬† I figured it would be easy enough to create the RAID array without clobbering the whole system and starting over… I was right… and it was a cool learning experience to boot.¬† I have sort-of (and I am really stressing that) created it as an interactive “ghetto-script” but I wrote that part AFTER I did everything manually… so be fore-warned.

#!/bin/bash
#
# Create a RAID 1 array from (2) new disks added to the system
#
# Determine what the new disks are (If you do not already know)
cat /proc/partitions
echo “OK your disk choices are listed above…”
echo “Select the first disk, press [ENTER]”
read disk1
echo “Now select the 2nd disk, press [ENTER]”
read disk2
echo “Just to confirm, these are the 2 disks you selected $disk1 & $disk2, enter[Y/N]”
read yesorno
#
if [[$yesorno == “Y”|| $yesorno == “y” ]]; then
echo “Great let’s move on”;
else echo “OK, let’s start again…”;
echo “ready?”; sleep 2;
bash test.sh
fi
#
echo “OK, there may be some interaction here”
echo “Also keep in mind that this will create a single full partiton on the disk(s)”
for i in $disk1 $disk2; do mkfs -t ext3 /dev/$i; done
echo “OK the file systems have been created. let’s create the array now”
mdadm –detail –scan
echo “What name would you like to use for your md device? i.e. md4, md5, etc…”
echo “Select something NOT listed above… :)”
read mdname
echo “Also, I need to know what RAID level u desire (0=stripe, 1=mirror, etc…)”
read Rlevel
mdadm –create /dev/$mdname –level=$Rlevel –raid-devices=2 /dev/$disk11 /dev/$disk21
# Make the ext3 filesystems on the new RAID device now
mkfs -t ext3 /dev/$mdname

uuid=`mdadm –detail /dev/md5|grep UUID|awk ‘{print $3}’`
echo “ARRAY /dev/$mdname level=raid1 num-devices=2 uuid=$uuid” >> /etc/mdadm.conf
# OR
echo “ARRAY /dev/$mdname level=raid1 num-devices=2 uuid=`mdadm –detail /dev/md5|grep UUID|awk ‘{print $3}’` >> /etc/mdadm.conf
echo “OK what r u going to mount this new array on”
read mountpt
echo “/dev/$mdname¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† /$mountpt¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬†¬† ext3¬†¬†¬† defaults¬†¬†¬†¬†¬†¬†¬† 1 2” >> /etc/fstab
mount -a
df -h
#
#
# EOF

Begining of the Notes section of the process:
for i in c d; do mkfs -t ext3 /dev/sd$i; done
mdadm:

[root@cent55vm ~]# cat /proc/partitions
major minor  #blocks  name

8     0   15728640 sda
8     1     104391 sda1
8     2   10498477 sda2
8     3    2562367 sda3
8     4    2562367 sda4
8    16   15728640 sdb
8    17     104391 sdb1
8    18   10498477 sdb2
8    19    2562367 sdb3
8    20    2562367 sdb4
8    32   12582912 sdc <РNEW Disk
8    48   12582912 sdd <РNEW Disk
9     0   10498368 md0
9     2    2562240 md2
9     1    2562240 md1
9     3     104320 md3

[root@cent55vm ~]# for i in c d; do mdadm –query /dev/sd$i; done
/dev/sdc: is an md device which is not active
/dev/sdc: No md super block found, not an md component.
/dev/sdd: is not an md array
/dev/sdd: No md super block found, not an md component.

[root@cent55vm ~]# mdadm –create /dev/md5 –level=1 –raid-devices=2 /dev/sd[cd]1
[root@cent55vm ~]# mdadm –stop –scan /dev/md5
mdadm: stopped /dev/md5
[root@cent55vm /]# mkfs -t ext3 /dev/md5
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
1572864 inodes, 3144688 blocks
157234 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=3221225472
96 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.
[root@cent55vm ~]# mdadm –query /dev/md5
/dev/md5: 11.100GiB raid1 2 devices, 0 spares. Use mdadm –detail for more detail.
/dev/md5: No md super block found, not an md component.

[root@cent55vm ~]# cat /etc/mdadm.conf

# mdadm.conf written out by anaconda
DEVICE partitions
MAILADDR root
ARRAY /dev/md0 level=raid1 num-devices=2 uuid=d8f8e0f1:caa5c290:62f0c003:e5ed749b
ARRAY /dev/md3 level=raid1 num-devices=2 uuid=ff5e4f19:159926bd:d6f963ca:e2b5dd18
ARRAY /dev/md2 level=raid1 num-devices=2 uuid=fdddc210:d340c10e:abec408b:83be0dfe
ARRAY /dev/md1 level=raid1 num-devices=2 uuid=9a79ae00:c847b003:d1212b6b:e1698b20
[root@cent55vm ~]# mdadm –detail /dev/md5|grep UUID
UUID : 746ec738:0867caf1:bcb45960:2e9b2dde
[root@cent55vm ~]# echo “ARRAY /dev/md5 level=raid1 num-devices=2 uuid=746ec738:0867caf1:bcb45960:2e9b2dde” >> /etc/mdadm.conf
[root@cent55vm /]# mdadm –detail /dev/md5
/dev/md5:
Version : 0.90
Creation Time : Tue Sep 21 09:18:15 2010
Raid Level : raid1
Array Size : 12578752 (12.00 GiB 12.88 GB)
Used Dev Size : 12578752 (12.00 GiB 12.88 GB)
Raid Devices : 2
Total Devices : 2
Preferred Minor : 5
Persistence : Superblock is persistent

Update Time : Tue Sep 21 09:59:58 2010
State : clean
Active Devices : 2
Working Devices : 2
Failed Devices : 0
Spare Devices : 0

UUID : 746ec738:0867caf1:bcb45960:2e9b2dde
Events : 0.2

Number   Major   Minor   RaidDevice State
0       8       33        0      active sync   /dev/sdc1
1       8       49        1      active sync   /dev/sdd1

, , , , , , , , ,

Leave a comment

VNC-me…


So I was messing around with VNC this past week since I haven’t posted anything in a while I thought I would share this trivial yet useful process to be up and running in a few minutes… Sorry if my notes are a bit scattered…

Set up  VNC server:

for root:
[root@oracler5u5 ~]# rpm -qa|grep vnc
vnc-4.1.2-14.el5_3.1
vnc-server-4.1.2-14.el5_3.1
from  /root: Or the users home dir:
mkdir .vnc
cd .vnc

vncpasswd
Password:
Verify:

vi xstartup
#!/bin/sh
# Add the following line to ensure you always have an xterm available.
( while true ; do xterm ; done ) &
# Uncomment the following two lines for normal desktop:
unset SESSION_MANAGER
exec /etc/X11/xinit/xinitrc
#
[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80×24+10+10 -ls -title “$VNCDESKTOP Desktop” &
twm &

cat /etc/sysconfig/vncservers
VNCSERVERS=”1:root 2:gmc 3:emf”
VNCSERVERARGS[1]=”-geometry 1152×864″
VNCSERVERARGS[2]=”-geometry 1152×864″
VNCSERVERARGS[3]=”-geometry 1152×864″

[root@oracler5u5 ~]# service vncserver restart
Shutting down VNC server: 1:root 2:gmc 3:emf               [  OK  ]
Starting VNC server: 1:root
New ‘oracler5u5.proserve.local:1 (root)’ desktop is oracler5u5.proserve.local:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/oracler5u5.proserve.local:1.log

2:gmc
New ‘oracler5u5.proserve.local:2 (gmc)’ desktop is oracler5u5.proserve.local:2

Starting applications specified in /home/gmc/.vnc/xstartup
Log file is /home/gmc/.vnc/oracler5u5.proserve.local:2.log

3:emf
New ‘oracler5u5.proserve.local:3 (emf)’ desktop is oracler5u5.proserve.local:3

Starting applications specified in /home/emf/.vnc/xstartup
Log file is /home/emf/.vnc/oracler5u5.proserve.local:3.log

[  OK  ]

Add approprite ports to iptables:
-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 5900 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 5902 -j ACCEPT
-A RH-Firewall-1-INPUT -p tcp -m state –state NEW -m tcp –dport 5903 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state –state NEW -m udp –dport 5900 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state –state NEW -m udp –dport 5901 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state –state NEW -m udp –dport 5902 -j ACCEPT
-A RH-Firewall-1-INPUT -p udp -m state –state NEW -m udp –dport 5903 -j ACCEPT

Done

Connect with VNC Viewer:

192.168.11.53:5901        root user as defined in /etc/sysconfig/vncservers
192.168.11.53:5902        gmc user as defined in /etc/sysconfig/vncservers
192.168.11.53:5903        emf user as defined in /etc/sysconfig/vncservers
cat /etc/sysconfig/vncservers
VNCSERVERS=”1:root 2:gmc 3:emf”
VNCSERVERARGS[1]=”-geometry 1152×864″
VNCSERVERARGS[2]=”-geometry 1152×864″
VNCSERVERARGS[3]=”-geometry 1152×864″

, , , , ,

Leave a comment

OpenSSL-1.0.0a on AIX v5.3


Well once again I find myself scrambling to get something done that was known but not well communicated during the project life-cycle.¬† So I need to update all managed AIX machines running v5.3 to include OpenSSL (openssl-1.0.0a to be exact) and once again my disdain for AIX rears it ugly head, which is represented by the Zombie to the left ūüôā¬† Aside from my personal dislike of the Korn shell… Maybe I am not being fair to AIX as I don’t really work in an AIX optimal environment, taking full advantage of all of the great tools they do have (NIM, clustering, SAN, etc…).¬† But managing them as 1-off’s just plain stinks.¬† Suffice it to say that I would NOT recommend deploying a stand-alone AIX server in any circumstance as you cannot realize anything near it’s full potential.¬† Anyway, here is what I did to rectify the issue at hand.

# Install SSL on AIX 5.3.0.0
# get the rpm.rte package on the system
mkdir /opt/ssl4AIX
cd /opt/ssl4AIX
installp -qacXgd rpm.rte rpm.rte
# Grab the other packages and put them on the AIX system
# http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/download.html
rpm -ivh gcc-4.2.0-3.aix5.3.ppc.rpm
rpm -ivh libgcc-4.2.0-3.aix5.3.ppc.rpm
# Create a sym link – Check this first following RPM installs for correct PATHS
# find / -name libgcc_s.a
# /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/ppc64/libgcc_s.a
# /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/pthread/ppc64/libgcc_s.a
# /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/pthread/libgcc_s.a
# /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_s.a
# Now make the link
ln -s /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.2.0/libgcc_s.a /usr/lib/libgcc_s.a
#
gunzip openssl-1.0.0a.tar.gz
tar -xf openssl-1.0.0a.tar
cd openssl-1.0.0a
./Configure shared –prefix=/usr aix-gcc
make
make test
# If all goes well !!!
make install

Incidentally, you need an IBM account if you want to download these packages from http://www-03.ibm.com/systems/power/software/aix/linux/toolbox/download.html&#8230; LOL

That stinks as well ūüė¶

, , , , , , , , ,

1 Comment