Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
You still don't need that last line. You've already performed the cd inside the IF section, you don't need to do it again. (This is not going to stop your script from working, I'm just removing unnecessary statements.)
But right now we do not encounter any mounting issue.
Script has worked.
I'd like to test the script.
How should I test?
Please note:
In the past on failure TAR backup has created on /root FS.
We do not want to create backup on /root.
I think this script will prevent to do TAR backup on /root FS.
It will create TAR backup only on defined path in the script.
Yes, I'm confident that the script will terminate if it can't find the directory it wants to put the archive in.
If you want to test it, try these things:-
Comment the "tar" command
Firstly, put a "#" at the start of the tar command, as well as any commands that you DON'T want executed (perhaps the mail commands as well)
Put the script in "debug" mode
At the top of the script, put the command "set -x". This will cause the script to show you each command as it runs.
set -x
umount /mnt/upgdp
mount 00.00.00.0:/bkup /mnt/upgdp
if [ -d /mnt/upgdp/dev2 ]; then
# The preferred directory exists, so use it
cd /mnt/upgdp/dev2
else
echo Mount is not available, try agin later | mutt -x -s "Backup Failed" Mail@mail.com
exit 1
fi
cd /mnt/upgdp/dev2
rm dev2.bk*
today=$(date '+%m%d%y')
#tar -czvf dev2.bk_"$today".tar.tgz /opt/IBM/WebSphere
/home/dn/TARStatus > /home/dn/TARStatus.log
#mail -s "TAR Backup for dev2 has been done" Mail@mail.com < /home/dn/TARStatus.log
Results:
++ umount /mnt/upgdp
++ mount 00.00.00.0:/bkup /mnt/upgdp
++ '[' -d /mnt/upgdp/dev2 ']'
++ cd /mnt/upgdp/dev2
++ cd /mnt/upgdp/dev2
++ rm 'dev2.bk*'
rm: cannot remove `dev2.bk*': No such file or directory
+++ date +%m%d%y
++ today=032510
++ /home/dn/TARStatus
Now users wants instead of backup failed message, if mount is not available on backup server1 (upgdp), it should place to backup server2 (bibbkp).
If both are not available then we get the backup failed message.
Could you correct below? thanks
umount /mnt/upgdp
mount 00.00.00.0:/bkup /mnt/upgdp
if [ -d /mnt/upgdp/dev2 ]; then
# The preferred directory exists, so use it
cd /mnt/upgdp/dev2
else
mount 00.00.00.0:/bigbkup/data /mnt/bigbkup
if [ -d /bigbkup/dev2 ]; then
cd /mnt/bigbkup/dev2
rm dev2.bk*
today=$(date '+%m%d%y')
tar -czvf dev2.bk_"$today".tar.tgz /opt/IBM/WebSphere
/home/dn/TARStatus > /home/dn/TARStatus.log
mail -s "TAR Backup for dev2 has been done on Server2" Mail@mail.com < /home/dn/TARStatus.log
exit 1
fi
else
echo Mount is not available, try agin later | mutt -x -s "Backup Failed" Mail@mail.com
exit 1
fi
cd /mnt/upgdp/dev2
rm dev2.bk*
today=$(date '+%m%d%y')
tar -czvf dev2.bk_"$today".tar.tgz /opt/IBM/WebSphere
/home/dn/TARStatus > /home/dn/TARStatus.log
mail -s "TAR Backup for dev2 has been done" Mail@mail.com < /home/dn/TARStatus.log
umount /mnt/upgdp /mnt/bigbkup
mount 00.00.00.0:/bkup /mnt/upgdp
if [ -d /mnt/upgdp/dev2 ]; then
# The preferred directory exists, so use it
cd /mnt/upgdp/dev2
Subject="TAR Backup for dev2 has been done on upgdp"
else
mount 00.00.00.0:/bigbkup/data /mnt/bigbkup
if [ -d /mnt/bigbkup/dev2 ]; then
cd /mnt/bigbkup/dev2
Subject="TAR Backup for dev2 has been done on bigbkup"
else
echo Mount is not available, try agin later | mutt -x -s "Backup Failed" Mail@mail.com
exit 1
fi
fi
rm dev2.bk*
today=$(date '+%m%d%y')
tar -czvf dev2.bk_"$today".tar.tgz /opt/IBM/WebSphere /home/dn/TARStatus > /home/dn/TARStatus.log
mail -s "$Subject" Mail@mail.com < /home/dn/TARStatus.log
A mount point - in this case /mnt/upgdp - is just a directory. Just like any other directory. If you create /mnt/upgdp as a directory, you can then put other data and subdirectories under it, just like a normal directory.
When you mount a file system on that mount point, the contents of the mounted file system are visible instead of the data and subdirectories you had there before. When you umount the file system, your existing data and subdirectories will "return". The fact is they didn't get deleted or lost, the mounted file system just takes precedence while it is mounted.
Does that explain what you're seeing?
When you have the file system mounted, you will see if in the output of the commands "df -k" or "df -h". When the file system is un-mounted, you won't see it using df because when the file system is un-mounted, the mount point is behaving like a normal directory entry and doesn't need to be in the "df" output.
Last edited by blacky_5251; 03-25-2010 at 06:05 PM.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.