Results 1 to 2 of 2
Hello, beginner bash scripter here.. I was able to write a script and it works just fine. I'm just wondering if someone could chime in or contribute any suggestions to ...
- 04-27-2009 #1Just Joined!
- Join Date
- Nov 2008
- Posts
- 9
Suggestions for bash script
Hello, beginner bash scripter here.. I was able to write a script and it works just fine. I'm just wondering if someone could chime in or contribute any suggestions to make it cleaner or tighter so to speak. I have a disk to disk backup solution which uses 250GB disks. When one gets full I just pop in a new one. the backup disk is also shared via NFS automount.
#!/bin/bash
#Unexport all nfs directories
echo unexporting nfs directories!
exportfs -au
#check to make sure unexport was successful!
exportfs -v
#umount BACKUPS
umount -v /BACKUPS
#replace the old drive with a new one
echo "Do you wish to continue? (y/n)"
read ans
case $ans in
Y|y) ;;
[Yy][Ee][Ss]) ;;
N|n) exit ;;
[Nn][Oo]) exit ;;
*) echo "Invalid command"
esac
#partiton and create new filesystem on the drive
# run fdisk to make sure we are using /dev/sdc
echo "RUNNING FDISK TO SEE IF /DEV/SDC IS THE CORRECT DRIVE!"
fdisk -l
echo "Are you ready to run fdisk? (y/n)"
read ans
case $ans in
Y|y) ;;
[Yy][Ee][Ss]) ;;
N|n) exit ;;
[Nn][Oo]) exit ;;
*) echo "Invalid command"
esac
echo "ABOUT TO CREATE THE NEW PARTITION!!!!!!!!!!!!!"
fdisk /dev/sdc < ~/250GB_format.txt
#check to see if the OS automounted the disk
echo #CHECKING TO SEE IF FEDORA AUTOMOUNTED THE DRIVE!!!!!!!!!!!!!!!!"
umount -v /dev/sdc1
#create the new filesystem
echo "ABOUT TO CREATE THE FILESYSTEM!!!!!!!!!!!!!!!!!!!"
mkfs.ext3 /dev/sdc1
#mount the new file system
echo "MOUNT THE FILESYSTEM!!!!!!!!"
mount -v /dev/sdc1 /BACKUPS
#run df to see that the filesystem is mounted an reporting the correct size
df -h
echo "Is the disk mounted and showing the correct partition size? (y/n)"
read ans
case $ans in
Y|y) ;;
[Yy][Ee][Ss]) ;;
N|n) exit ;;
[Nn][Oo]) exit ;;
*) echo "Invalid command"
esac
#get the UUID to add to fstab
echo "GRAB THE BLOCKID"
blkid /dev/sdc1
#export the filesystems
echo "EXPORTING /BACKUPS"
exportfs -av
- 04-28-2009 #2Just Joined!
- Join Date
- Apr 2009
- Posts
- 90
You may want to consider GlusterFS?


Reply With Quote