LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This 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


Reply
  Search this Thread
Old 03-24-2010, 06:05 PM   #16
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15

Looks its going to be work.
I will update u shortly

Please note:
I do not want to create backup on /root on the failuer.


Thanks
 
Old 03-24-2010, 06:17 PM   #17
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
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.)

Is it working now?
 
Old 03-24-2010, 06:44 PM   #18
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
Yes, it is working.

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.

Is it correct?

Last edited by dnaqvi; 03-24-2010 at 06:45 PM.
 
Old 03-24-2010, 06:49 PM   #19
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
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:-
  1. 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)
  2. 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.
 
Old 03-25-2010, 11:19 AM   #20
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
My Testing Results:

Script:

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

is it ok?

Many thanks for all of your help.

D
 
Old 03-25-2010, 12:19 PM   #21
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
Can you help me on following too?

http://www.linuxquestions.org/questi...ep-w-e-797568/

Thanks
 
Old 03-25-2010, 03:38 PM   #22
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Yes, it all looks correct. Remove the test changes you made (i.e. set -x and the comments) and you can then use the script.
 
Old 03-25-2010, 04:10 PM   #23
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
We have two backup servers.

upgdp (in script above) and bigbkp

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
 
Old 03-25-2010, 05:09 PM   #24
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
Try this code:-
Code:
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
 
Old 03-25-2010, 05:50 PM   #25
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
Do you think its normal behaviour?

I umount upgdp as

umount /mnt/upgdp

but still I can go to the following directory.

cd /mnt/upgdp/wps2
> /mnt/upgdp/wps2

Actually I am testing new script , I am thinking to umount upgdp and put # b4 mount 00.00.00.0:/bkup /mnt/upgdp and run the script.

But in this case script will pick cd /mnt/upgdp/wps2 and do the backup on /mnt/upgdp/wps2.

Is it really umount?

thanks
 
Old 03-25-2010, 05:55 PM   #26
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
OK, a quick overview of mount points.

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.
 
Old 03-25-2010, 06:19 PM   #27
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
This problem has been solved.

One of our team created the directory in the dev2 byitself.
I will test the script and update to you
 
Old 03-25-2010, 06:26 PM   #28
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
from above after deleting dev2 directory from the server itself.
I have umount upgdp

Now I am getting this message.
I think this is expected.


cd /mnt/upgdp/dev2
-bash: cd: /mnt/upgdp/dev2: No such file or directory

No I will test script.
 
Old 03-25-2010, 06:32 PM   #29
blacky_5251
Member
 
Registered: Oct 2004
Location: Adelaide Hills, South Australia
Distribution: RHEL 5&6 CentOS 5, 6 & 7
Posts: 573

Rep: Reputation: 61
If dev2 exists in the remote file system, as I think it does, and you have unmounted the remote file system, then this is expected behaviour.
 
Old 03-25-2010, 07:51 PM   #30
dnaqvi
Member
 
Registered: Oct 2009
Posts: 117

Original Poster
Rep: Reputation: 15
Many Thanks


All options are working.
Is it possible for you to look at my other request too?

http://www.linuxquestions.org/questi...ep-w-e-797568/



Thanks
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to backup using tar emymcse Linux - Server 1 09-21-2008 07:29 AM
BackUp & Restore with TAR (.tar / .tar.gz / .tar.bz2 / tar.Z) asgarcymed Linux - General 5 12-31-2006 02:53 AM
Cannot take tar backup nevillemonteiro Linux - Enterprise 1 08-25-2006 03:21 AM
Tar backup TheRealDeal Linux - General 7 02-08-2005 03:25 PM
Using tar for backup. TheRealDeal Linux - General 2 08-10-2004 11:46 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 12:19 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration