Operating System - HP-UX
1748211 Members
4831 Online
108759 Solutions
New Discussion юеВ

Re: copy a filesystem best solution (local host or remote host)

 
SOLVED
Go to solution
Billa-User
Regular Advisor

copy a filesystem best solution (local host or remote host)

hello,

what is the best and safest solution to copy a filesystem

- local host: to a new mounted filesystem
- remote host: to a remote new server and new mounted filesystem

commands : "cpio", "dd" or "cp/rcp" or "tar" ?
why ? we will get a new storage system. sometimes old and new storage were connected and new storage where activated in a new vg and mounted as a new mount-point.
or sometimes we have a new server !

command "cpio" :
Local Host:
# Check, Files > 2 GB /old_fs
find /old_fs -xdev -size +2097152000c
OK:
cd /old_fs
find . ! -name lost+found -depth -print | cpio -padlmuv /new_fs

Remote Host:
RET_DIR=$( remsh server -n '(test -d /new_fs;echo $?) `
cd /old_fs
find . ! -name lost+found -depth -print | cpio -oc | remsh server "cd /new_fs; cpio -icdlumv"

Files < 2 GB will copied by "cp/rcp"

command "dd" :
Check, if filesystems have the same version and lvol has the same size
Local Host:
dd if=/dev/vgold_fs/rold_fs of=/dev/vgnew_fs/rnew_fs bs=1024k
Remote Host:
dd if=/dev/vgold_fs/rold_fs ibs=1024k | remsh server "dd of=/dev/vgnew_fs/rnew_fs obs=1024k "

note: filesystems during copy are umounted and after finish a fsck will done
is "cp/rcp" or "tar a alternative ?

regards
113 REPLIES 113
klb
Valued Contributor

Re: copy a filesystem best solution (local host or remote host)


Looks like you've done your homework!! :)

You've got plenty of ideas for the local copy, for remote copy, I generally use this:

#!/bin/ksh
# run this script on the remote host where
# you want the copied files to go
#
# Start this script in the destination folder
RGZIP="/usr/contrib/bin/gzip -1"
LGZIP="/usr/contrib/bin/gzip -d"
remsh source_host -n \
"cd head_of_source_tree;tar cvf - . |$RGZIP" | $LGZIP |tar xvf -

...placement of the quotes is important.

If your target and source hosts are on the same subnet ( very close together ), the gzip may slow it down a bit, but if theres a bit of network between them, the gzip will help with speed.

Hth,

-klb

Michael Steele_2
Honored Contributor

Re: copy a filesystem best solution (local host or remote host)

rsync --progress -avh /source/ user@/dest/
Support Fatherhood - Stop Family Law
Mel Burslan
Honored Contributor

Re: copy a filesystem best solution (local host or remote host)

If you have the luxury of time and taking the applications using the filesystem down, I will agree with Michael and suggest using rsync.

another way is using vxdump/vxrestore as follows:

vxdump 0f - ${SOURCEFS} | (cd ${DESTINFS} ; vxrestore xf -)

This is for the local system. You can use the same "remsh remote-server" construct in your original question, for copying to the remote server.
________________________________
UNIX because I majored in cryptology...
Bob_Vance
Esteemed Contributor

Re: copy a filesystem best solution (local host or remote host)

I got in the habit of using 'fbackup(frecover)' because it was the only backup on HPUX that would do ACLs( Access Control Lists)
'fbackup' is still included on 11.31.

'fbackup' is also pretty sophisticated, supporting double-buffering, and you can tweak its performance.

My technique is simlar to Mel's (note that vxdump does not support ACLs either):



*******************
For a Local copy:
*******************
# tweak some fbackup parms
# 4 blocks required for pipe into frecover (def=16) to avoid err:
# "frecover(2104): zero length read from disk file. Frecover exiting"
# 3 readers for triple buffering

## echo > /tmp/fbc '
blocksperrecord 4
readerprocesses 3
'

## (cd /tmp/bvd1/ ; fbackup -c /tmp/fbc -f - -i . -e ./lost+found ) \
| (cd /tmp/bvd2/ ; frecover -rf - )

(note that we are excluding the mountpoint lost+found dir)


*******************
For a Network copy:
*******************
# tweak some fbackup parms
# 1 block sufficient for a network copy
# 2 readers for double buffering

## echo > /tmp/fbc '
blocksperrecord 1
readerprocesses 2
'

## (cd /tmp/bvd1/ ; fbackup -c /tmp/fbc -f - -i . -e ./lost+found ) \
|(ssh pine4 \
cd /tmp/bvd2/ \; frecover -rf - )
------------------------------^^^^^
notice the backslash before the semicolon



Of course, you probably are not using ACLs, so you can use the same technique and use any backup that supports symbolic links, like even 'tar -cf -' into 'tar xf -'



bv
"The lyf so short, the craft so long to lerne." - Chaucer
James R. Ferguson
Acclaimed Contributor

Re: copy a filesystem best solution (local host or remote host)

Hi:

As usual, TIMTOWTDI. See my comments in this thread:

http://h30499.www3.hp.com/t5/System-Administration/migrating-from-lvol1-to-lvol2-onto-a-different-drive/m-p/4344245#M343952

Remember, 'fbackup/frestore' is an HP-UX only product and sadly deprecated at 11.31 at that.

Regards!

...JRF..

Billa-User
Regular Advisor

Re: copy a filesystem best solution (local host or remote host)

hello,
I would like to thank you for posts. i good a lot of new informations and new commands. i have to test the new commands. then i will post my experiences.

@ Mel Burslan
I will have the luxury of time and taking the applications using the filesystem down !

when processes write in a filesystem and i will copy the filesystem to another filesystem,then filesystem one and filesystem new is not equal ? i must have a "exclusive" access to a filesystem for copy ?
maybe "umount" and "mount" it like "/mount_copy" ?

regards
Hakki Aydin Ucar
Honored Contributor

Re: copy a filesystem best solution (local host or remote host)

when it comes to copy a file system, never pass the ignite. the one of the main purpose of ignite to backup file systems and restore of course. You can also keep the copy of backup on the media, tape.
Just look at the man page and numerous docs here for ignite.
Bob_Vance
Esteemed Contributor

Re: copy a filesystem best solution (local host or remote host)

> maybe "umount" and "mount" it like "/mount_copy" ?

Good catch!
Another option is:

umount /mount
mount -r /mount

for read-only mode.

bv
"The lyf so short, the craft so long to lerne." - Chaucer
Billa-User
Regular Advisor

Re: copy a filesystem best solution (local host or remote host)

@ mount -r /mount
@ for read-only mode.

good input, thx