Operating System - HP-UX
1844204 Members
2068 Online
110229 Solutions
New Discussion

Moving files to different logical volume with same directory structure

 
Leigh Williams
Occasional Contributor

Moving files to different logical volume with same directory structure

Hello all,

This may just be a stab in the dark but is there anyway you can move files from one logical volume to another when they have the same directory structure?

I have filesystem /danaadl/baan/patches which lives on /dev/vg01/lvol7 and I want to move it back to /danaadl on /dev/vg03/lvol1 keeping the same directory structure.

TIA
Leigh
7 REPLIES 7
Philip Chan_1
Respected Contributor

Re: Moving files to different logical volume with same directory structure

"mv /danaadl/bann/patches /danaadl" should do it.

You don't have to worry by yourself which logical volume the data would reside on. After the "mv" command the data will be seating on /dev/vg03/lvol1.

~Philip
David Mabo_1
Advisor

Re: Moving files to different logical volume with same directory structure

Yes. use the mv command. The -r option will do it recursive, but your can do

mv /danaadl/baan/patches/* /danaadl

many will recomend using a copy and delete so that if there is a space problem, you do not loose the files. I recomend a backup.

One other trick I have used is to make a tape from the direcotry and restore it to the directory; ei
cd /danaadl/baan/patches
tar cvf /dev/rmt/0m .
cd /danaadl
tar xvf /dev/rmt/0m

and then delete the files. This will take more time. Another way to skin a job.
Rodney Hills
Honored Contributor

Re: Moving files to different logical volume with same directory structure

You can use tar to move a directory structure by the following

cd
tar cf - . | (cd ; tar xf -)

This will do a disk to disk copy. Note if you are using ACLs they will not be copied. See man frecover for how to use fbackup/frecover to do the same thing
There be dragons...
Patrick Wallek
Honored Contributor

Re: Moving files to different logical volume with same directory structure

Leigh,

If you want to keep the exact same directory structure on both LVs then I would do something like the following:

# umount /dev/vg03/lvol1 --> unmount the lvol you are moving the info. to

#mkdir /danaadl.new --> make a new directory to mount to

# mount /dev/vg03/lvol1 /danaadl.new --> remount the new lvol to a different directory name

# cd /danaadl

#cp -Rp ./* /danaadl.new --> copy the stuff from your current directory to the new one

#cd /

# umount /danaadl --> unmount current directory

# umount /danaadl.new --> unmount new directory

# mount /dev/vg03/lvol1 /danaadl --> mount new directory with correct directory name

You could now 'mount /dev/vg01/lvol1 /danaadl.old' if you still need access or if you want to clean out the lvol. Or you could just remove the lvol if you don't need it anymore.

This is the only way I know of to move data between logical volumes and still keep the same directory name and structure.
Shannon Petry
Honored Contributor

Re: Moving files to different logical volume with same directory structure

I have a bit of a twisted way of moving things, mainly to considre special files (PIPE/FIFO/B/C). I found that cpio is a bit faster than tar, and gives you the same result.

Lets assume we have "/olddir/data" and you need it moved to "/newdir/data"
make sure that "/newdir/data" exists and has the space needed. Just do
>cd /olddir/data
>/bin/find . -depth -print | /bin/cpio -padlmuxv /newdir/data

You can verify the contents of /newdir/data before removing the old stuff.
man cpio for more information...

Regards,
Shannon
Microsoft. When do you want a virus today?
Tim Malnati
Honored Contributor

Re: Moving files to different logical volume with same directory structure

I use the rdist utility all the time for data moves. It is particularly useful in situations where there is a lot of data and there is a potential that the source may be modified during the transition. This does not seem to be the case in your situation (mv will handle it fine), but may be useful down the road.
Jaimin Parikh
Frequent Advisor

Re: Moving files to different logical volume with same directory structure

Hi,

I think you can use pvmove command also.Check the man pages for pvmove command.It will give you better idea.

Also,instead of 'tar' I would suggest use 'fbackup' since it will do everything for you.Check out 'fbackup' also.

Regards,
Jaimin
JAIMIN PARIKH : Share your knowledge and help those who need your help!!