Posts Tagged share

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

Advertisements

, , , , , , , , , ,

Leave a comment

20 lines or less to NFS !


I was looking through the Linux Magazine links on facebook again and came across another nifty little topic that is fairly usable in almost every scenario, NFS.  I thought it was funny that I found several blog postings that had lots of replies that the steps outlined didn’t work !  I know I am a stickler, but see I told you that was the case… this one is functional on CentOS v5.5… So in less than 20 lines, you can share all day on your Linux boxes…

# Server-side:
yum install -y nfs-utils nfs-utils-lib
echo “/home/software 192.168.11.141(rw,sync)” >> /etc/exports
echo “/home/scripts 192.168.11.141(rw,sync)” >> /etc/exports
echo “portmap: 192.168.11.0/255.255.255.0” >> /etc/hosts.allow
exportfs -a -v
for i in nfs portmap; do chkconfig $i on; done
for i in tcp udp; do iptables -A INPUT -p $i -m $i -m multiport –dports 1110,2049 -j ACCEPT; done
iptables-save > /etc/sysconfig/iptables
service portmap start
service nfs start
#
# Client-side:
service portmap start
chkconfig portmap on
cd /
mkdir fx6-share
mount 192.168.11.64:/home/software /fx6-share
# Make it stick:
echo “192.168.11.64:/home/software /fx6-share         nfs     defaults        0 0” >> /etc/fstab
echo “192.168.11.64:/home/scripts /fx6-scripts         nfs     defaults        0 0” >> /etc/fstab
mount -a
# EOF

, , , , , , ,

2 Comments

Solaris 10 – n- NFS


I fired out an NFS share from a Solaris 10 box today for a Windows and Linux share… I thought I would post my “quick -n- dirty” steps… The Windows share required the installation of the UNIX for Windows tools… it comes on the CD 🙂

Add the new filesystems you want to share:
sunblade # cat /etc/dfs/sharetab
/a              –       nfs     rw      FACTS
/export/home    –       nfs     rw      FACTS
/usr6           –       nfs     rw      FACTS_TEST

execute “shareall” @ the command line:

execute /etc/init.d/nfs.server start <– ensure changes are taken

On the server you want to mount on:
create the mount points on / :

drwxrwxrwx  14 root     root         512 Sep  1 16:12 a_sunblade
drwxr-xr-x  44 root     root        1024 Feb 10 16:22 usr6_sunblade

then mount the filesystems you want:
# mount sunblade:/a /a_sunblade
# mount sunblade:/usr6 /usr6_sunblade
# df -h |grep sunblade
sunblade:/a             17G    10G   7.0G    60%    /a_sunblade
sunblade:/usr6          33G    17G    16G    52%    /usr6_sunblade

fstab entry for NFS mount:
[root@centOS54 /]# cat /etc/fstab
/dev/VolGroup00/LogVol00 /                       ext3    defaults        1 1
LABEL=/boot             /boot                   ext3    defaults        1 2
tmpfs                   /dev/shm                tmpfs   defaults        0 0
devpts                  /dev/pts                devpts  gid=5,mode=620  0 0
sysfs                   /sys                    sysfs   defaults        0 0
proc                    /proc                   proc    defaults        0 0
/dev/VolGroup00/LogVol01 swap                    swap    defaults        0 0
SFX4140P:/export/home   /SFX4140P               nfs     rsize=8192,wsize=8192,timeo=14,intr <– this one

, , , , , ,

Leave a comment