Posts Tagged mount

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

Advertisements

, , , , , , , , , , ,

Leave a comment

Solaris 10 disk extending


So I had a job recently that had an OS requirement for Solaris 10… Ya I am a UNIX guy, but all flavors are a little different, you know, but far be it from me to turn down an assignment just because I don’t know what I am doing, right? Well that is me… “do something, even if it’s wrong.”

Here are my notes on how I got through this one and keep in mind that everything worked out perfectly, until the customer decided to change their mind on the partitioning scheme… That presented some additional issues that I have outlined here… Unlike AIX, which compared to Solaris, is pretty straight forward… here is what I did…

Oh ya.. I forgot that they also ended up asking for an NFS mount… 2 actually, so I included that @ the end as a ‘BONUS’ as well… 🙂

Tar up and move all data on each partition as this process will wipe the partitions. That Means ALL DATA will be destroyed… Make a friggin’ back-up… LOL !!

Unmount the affected partitions and comment them out in /etc/vfstab <– This is more important than you think (LOL)
# umount /a
# umount /export/home

Now format the partition table <– This just takes you to the menu, it is not formatting the partition…
# format
Searching for disks…done

AVAILABLE DISK SELECTIONS:
0. c1t0d0 <– You may have more than 1 selection here, pick the right one. This is a 4 disk RAID 10 array so the OS thinks it’s only 1 disk…
/pci@0,0/pci10de,375@f/pci108e,286@0/disk@0,0
Specify disk (enter its number): 0
selecting c1t0d0
[disk formatted]
Warning: Current Disk has mounted partitions. <– Ignore this unless you are trying to do something with the listed mounted filesystems…
/dev/dsk/c1t0d0s0 is currently mounted on /. Please see umount(1M).
/dev/dsk/c1t0d0s1 is currently used by swap. Please see swap(1M).

FORMAT MENU:
disk – select a disk
type – select (define) a disk type
partition – select (define) a partition table
current – describe the current disk
format – format and analyze the disk
fdisk – run the fdisk program
repair – repair a defective sector
label – write label to the disk
analyze – surface analysis
defect – defect list management
backup – search for backup labels
verify – read and display labels
save – save new disk/partition definitions
inquiry – show vendor, product and revision
volname – set 8-character volume name
! – execute , then return
quit
format> verify

Primary label contents:

Volume name = < >
ascii name =
pcyl = 35667
ncyl = 35665
acyl = 2
bcyl = 0
nhead = 255
nsect = 63

Here is where you make the actual changes to the sizes.  You need to review the Block allocations and adjust them properly or nothing works.  If it is not obvious or unless you have unpartitioned FREE space, you will need to REDUCE the larger filesystem FIRST to have FREE space to grow the other filesystem(s).  makes sense right? LOL … You will also have to employ a bit of mathematics as well as guess work (@ least I had to) as there is a variance in the block (or GB) allocation you give that do not exactly match perfectly by human standards… You will see what I mean, but don’t get frustrated, just reduce the count by 1 or 2 blocks and all will be fine, the percentages will remain perfect however.

I am reducing /export/home to grow /a… by their equivalent:

Part Tag Flag Cylinders Size Blocks
0 root wm 96 – 2900 21.49GB (2805/0/0) 45062325
1 swap wu 1 – 95 745.20MB (95/0/0) 1526175
2 backup wm 0 – 35664 273.21GB (35665/0/0) 572958225
3 unassigned wm 18837 – 35664 128.91GB (16828/0/0) 270341820
4 unassigned wm 0 0 (0/0/0) 0
5 unassigned wm 0 0 (0/0/0) 0
6 unassigned wm 0 0 (0/0/0) 0
7 home wm 2901 – 18836 122.08GB (15936/0/0) 256011840
8 boot wu 0 – 0 7.84MB (1/0/0) 16065
9 unassigned wm 0 0 (0/0/0) 0

format>
label, name (default is a fine name) and save the new partitons

Now create the new (or same filesystem(s)) You can get this info from the /etc/vfstab file, the
lines that you commented out before are used below.

All changed partitons must be ‘newfs’ this is a completely destructive process !!! All data will be lost.
# newfs -v /dev/rdsk/c1t0d0s3
newfs: construct a new file system /dev/rdsk/c1t0d0s3: (y/n)? y
pfexec mkfs -F ufs /dev/rdsk/c1t0d0s3 400516515 63 -1 8192 1024 264 1 166 8192 t 0 -1 8 128 n
Warning: 4702 sector(s) in last cylinder unallocated
/dev/rdsk/c1t0d0s3: 400516514 sectors in 65189 cylinders of 48 tracks, 128 sectors
195564.7MB in 4075 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
Initializing cylinder groups:
…………………………………………………………………….
..
super-block backups for last 10 cylinder groups at:
399610016, 399708448, 399806880, 399905312, 400003744, 400102176, 400200608,
400299040, 400397472, 400495904

# newfs -v /dev/rdsk/c1t0d0s7 <– What psycho @ SUN came up with this disk naming scheme???
newfs: /dev/rdsk/c1t0d0s7 last mounted as /export/home
newfs: construct a new file system /dev/rdsk/c1t0d0s7: (y/n)? y
pfexec mkfs -F ufs /dev/rdsk/c1t0d0s7 125837145 63 -1 8192 1024 264 1 166 8192 t 0 -1 8 128 n
Warning: 4264 sector(s) in last cylinder unallocated
/dev/rdsk/c1t0d0s7: 125837144 sectors in 20482 cylinders of 48 tracks, 128 sectors
61443.9MB in 1281 cyl groups (16 c/g, 48.00MB/g, 5824 i/g)
super-block backups (for fsck -F ufs -o b=#) at:
32, 98464, 196896, 295328, 393760, 492192, 590624, 689056, 787488, 885920,
Initializing cylinder groups:
…………………….
super-block backups for last 10 cylinder groups at:
124951456, 125049888, 125148320, 125246752, 125345184, 125443616, 125542048,
125640480, 125738912, 125829152

Now uncomment the /etc/vfstab entries for these partitions and execute mount -a to remount
all partitions.

# df -hk
Filesystem size used avail capacity Mounted on
/dev/dsk/c1t0d0s0 21G 4.0G 17G 19% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 7.0G 964K 7.0G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
/usr/lib/libc/libc_hwcap2.so.1
21G 4.0G 17G 19% /lib/libc.so.1
fd 0K 0K 0K 0% /dev/fd
swap 7.0G 63M 7.0G 1% /tmp
swap 7.0G 28K 7.0G 1% /var/run
/dev/dsk/c1t0d0s3 188G 146M 186G 1% /a
/dev/dsk/c1t0d0s7 59G 60M 58G 1% /export/home

SFX4140T: <– This is what the original partitioning scheme was for these 2 filesystems:
/dev/dsk/c1t0d0s3 127G 64M 126G 1% /a
/dev/dsk/c1t0d0s7 120G 64M 119G 1% /export/home

* BONUS *

NFS mounting:
Ensure NFS is running:
# ps -ef |grep nfs
daemon 386 1 0 Feb 23 ? 0:00 /usr/lib/nfs/lockd
root 1299 1224 0 11:24:15 pts/2 0:00 grep nfs
daemon 378 1 0 Feb 23 ? 0:00 /usr/lib/nfs/nfs4cbd
daemon 379 1 0 Feb 23 ? 0:00 /usr/lib/nfs/statd
daemon 380 1 0 Feb 23 ? 0:04 /usr/lib/nfs/nfsmapid

On server you want to mount disks from:
sunblade # cat /etc/dfs/dfstab
# Place share(1M) commands here for automatic execution
# on entering init state 3.
#
# Issue the command ‘/etc/init.d/nfs.server start’ to run the NFS
# daemon processes and the share commands, after adding the very
# first entry to this file.
#
# share [-F fstype] [ -o options] [-d “”]
[resource]
# .e.g,
# share -F nfs -o rw=engineering -d “home dirs” /export/home2
share -F nfs -o rw -d “home dirs” /export/home
share -F nfs -o rw -d “FACTS” /a <– this was added
share -F nfs -o rw -d “FACTS_TEST” /usr6 <– this was added
#share -F nfs -o rw -d “home dirs” /usr4/export
#share -F nfs -o rw -d “home dirs” /usr4/sfa
#share -F nfs -o rw -d “home dirs” /usr4/ups
#share -F nfs -o rw -d “home dirs” /usr4/neoforma/in
#share -F nfs -o rw -d “home dirs” /usr4/neoforma/out
#share -F nfs -o rw -d “home dirs” /usr4/medibuy/in
#share -F nfs -o rw -d “home dirs” /usr4/medibuy/out
#share -F nfs -o rw -d “home dirs” /usr4/import

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

, , , , , , , , , ,

1 Comment