Operating System - HP-UX
1748268 Members
3722 Online
108760 Solutions
New Discussion юеВ

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

 
SOLVED
Go to solution
kpatel786
Frequent Advisor

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
10 REPLIES 10
Dennis Handly
Acclaimed Contributor

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

How are you getting it to do /var.bak and /stand.bak?
kpatel786
Frequent Advisor

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.
Peter Nikitka
Honored Contributor
Solution

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"
kpatel786
Frequent Advisor

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.
Dennis Handly
Acclaimed Contributor

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".
kpatel786
Frequent Advisor

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.
James R. Ferguson
Acclaimed Contributor

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...




kpatel786
Frequent Advisor

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.
kpatel786
Frequent Advisor

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

.