Re: renaming / as /root.bak while taking vxdump backup (236 Views)
Reply
Frequent Advisor
kpatel786
Posts: 74
Registered: ‎07-08-2008
Message 1 of 11 (236 Views)
Accepted Solution

renaming / as /root.bak while taking vxdump backup

Hi, I have written a script which backs up all the file system is list as .bak with vxdump
for ex:-

/var --> /var.bak
/stand --> /stand.bak
and so on

Below is my script:-
===>
set -vx
TAPE=/backup/networker_db_backup/os_app
HOST=`hostname`
FILESYSTEMS=`cat /test/filesystems_to_backup_V3`
echo "STARTING BACKUP OF $HOST `date`"
cd /
for i in $FILESYSTEMS
do
echo "STARTING BACKUP OF $i `date`"
/usr/sbin/vxdump -0 -u -b 128 -B 200g -f ${TAPE}${i}.bak $i 2>&1
if [ $? -gt 0 ] ; then
echo "BACKUP FAILED FOR $i `date`"
exit 1
else
echo "BACKUP COMPLETED FOR $i `date`"
fi
done
echo "END OF BACKUP SCRIPT"
====>

The problem is it backs / as:
/ --> .bak
and want it to be backed as below:
/ --> /root.bak

if I repalce the / with root in the file list it won't back the / filesytem. Kindly assist with your inputs.

Thanking you in advance
Acclaimed Contributor
Dennis Handly
Posts: 25,291
Registered: ‎03-06-2006
Message 2 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

How are you getting it to do /var.bak and /stand.bak?
Frequent Advisor
kpatel786
Posts: 74
Registered: ‎07-08-2008
Message 3 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

/usr/sbin/vxdump -0 -u -b 128 -B 200g -f ${TAPE}${i}.bak $i 2>&1

${i}.bak ---> this part does that.
Honored Contributor
Peter Nikitka
Posts: 1,575
Registered: ‎02-10-2003
Message 4 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

Hi,

try this:
...
echo "STARTING BACKUP OF $i `date`"
j=${i#/}
/usr/sbin/vxdump -0 -u -b 128 -B 200g -f ${TAPE} /${j:-root}}.bak $i 2>&1
if [ $? -gt 0 ] ; then
...

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
Frequent Advisor
kpatel786
Posts: 74
Registered: ‎07-08-2008
Message 5 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

Hi Peter,

I pressume this will only back / area. But what I intend to do is back up all the files in $FILESYSTEMS in for loop.
Currently it is doing so for all the filesystem however it is backing the / as .bak which I need to do as root.bak along with all the other filesystems.

Hope you understood.
Acclaimed Contributor
Dennis Handly
Posts: 25,291
Registered: ‎03-06-2006
Message 6 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

>I presume this will only back / area.

Peter's logic will remove the "/" from the name, then if there is nothing left, it will insert "root".
Frequent Advisor
kpatel786
Posts: 74
Registered: ‎07-08-2008
Message 7 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

To be frank I have not understood the logic. If this logic is backing all the filesystem along with / renaming then I have found GOD.

If possible kindly explain the logic.

Thanks.
Acclaimed Contributor
James R. Ferguson
Posts: 21,184
Registered: ‎07-06-2000
Message 8 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

hi:

> To be frank I have not understood the logic.

To see what Peter has done (to solve your problem), run this test script:

# cat ./seehow
#!/usr/bin/sh
for i in / /root /tmp /var
do
j=${i#/}
echo /usr/sbin/vxdump -0 -u -b 128 -B 200g -f ${TAPE} /${j:-root}.bak $i
done

The statement:

j=${i#/}

...examines the 'i' parameter and if it begins with the '/' character, then that character is dropped and the remainder of the character string is assigned to 'j'. Otherwise, the value of 'i' is simply assigned to 'j'.

The experssion:

/${j:-root}.bak

...is of the form:

${parameter:-word}

...which says, if the parameter is set and is nonnull, substitute its value; otherwise, substitute word. Hence, if 'j' is set and not null, use the value of 'j'; otherwise, substitute the string "root".

These techniques are described in the 'sh-posix' manpages under "Parameter Substitution":

http://docs.hp.com/en/B3921-60631/sh-posix.1.html

Regards!

...JRF...




Frequent Advisor
kpatel786
Posts: 74
Registered: ‎07-08-2008
Message 9 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

Thank you all for your reply have got the required output.

Special thanks to Peter and James.
Frequent Advisor
kpatel786
Posts: 74
Registered: ‎07-08-2008
Message 10 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

.
Honored Contributor
Peter Nikitka
Posts: 1,575
Registered: ‎02-10-2003
Message 11 of 11 (236 Views)

Re: renaming / as /root.bak while taking vxdump backup

Hi,

thanks to Dennis + James for the excellent explanation of the construct I used.
I really try not to leave questions to my work uncommented, but had to leave unexpectedly.

mfG Peter
The Universe is a pretty big place, it's bigger than anything anyone has ever dreamed of before. So if it's just us, seems like an awful waste of space, right? Jodie Foster in "Contact"
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.