Hi all
Thanks to Larry Church, Joe Spanicek, Neil Preston, Rich McClellan,
Tom Webster, Anthony D'Atri, Arne Steinkamm, Barry Lynam, Huw Davies,
Carl Privitt, Dougal Scott, Glenn Rickersey, Michael Cordonsky,
Andreas Bungert, David R. Courtade, Knut Helleboe, Karl Liebert,
ray bowen, John Schaeffer, Pat Villani, Dr. Thomas P. Blinn,
Tom Rioux, Menelaos Nicholaos Karamichalis, Mark Dudley, and
Marco Luchini for their responses. The original message is
included at the end of the summary.
Most suggested using either tar or cpio.
The recommendations for tar all used some variant of:
(cd /source/directory; tar cf - . ) | (cd /dest/directory; tar xvfp -)
One big advantage that many replies mentioned was that tar works
on just about all flavours of Unix. Dougal Scott pointed out one
catch with tar which is that it has a strict limit of 100 characters
for the filename including the path.
The suggested methods for cpio used variants of:
cd /source/dir; find . -depth -print | cpio -vdump /dest/dir
John Schaeffer recommended:
cd /dirtocopy; find . -print -depth | cpio -pdml /newdir
m - preserves modification times.
l - copies the links.
d - creates directories
John said: "This works fine under ultrix, but I did have some
problems with -depth under osf3.2c."
Joe Spanicek and Karl Liebert suggested using mv. The man page
description of how mv works across file systems implies to me
that it won't do what I want. My other worry about using mv is that
I like to make sure everything is working okay on the new disk
before I remove the original files. I suppose if your backups are
right up to date.
Glenn Rickersey recommended the gnu cp for this purpose. He and
Knut Helleboe also mentioned pax as another possibility.
Karl Liebert said: 'dump does work on "subtrees" on a partition.'
I didn't know this. The man page for dump uses the term file
system which I took to mean a complete file system.
Many replies said that cp was not intended for this purpose although
my interpretation of the cp man page description of the p and R
flags lead me to believe that `cp -pR` should do the job.
As a few people mentioned (Arne Steinkamm in particular) the R
flag to cp is not available or doesn't work the same on all Unixes
which was one reason to avoid using the cp command in this way.
Tom Webster did some quick tests and found that under DU 3.2D-1 cp
worked as expected so maybe there is a bug in our version of cp.
I think I'll stick to dump and restore for copying complete file
systems and tar for copying directories as most replies suggested.
Thanks to everyone.
=====================================================================
> I recently had to copy a complete file system from one disk
> to another. Naively I first tried `cp -pR`. As you probably
> realize this didn't work. Specifically, in order of increasing
> seriousness:
>
> o Directories had their modification times set to the
> time of copying rather than the same time as the source.
>
> o Files with the sticky bit set on the source did not have
> the sticky bit set on the destination.
>
> o Symbolic links were recreated as promised by the -R option
> but they had the wrong owner:group set. All recreated
> symbolic links had root:system as owner:group.
>
> With the help of the archives for this mailing list I discovered
> that the correct way to copy a complete file system was with dump
> and restore. Specifically
>
> dump -0f - file_system | (cd /mnt; restore -vrf -)
>
> does what I wanted.
>
> My problem is that I sometimes need to move a user's area from
> one disk to another. Since this is only part of a file system
> I can't use dump and restore although I suppose I could use tar
> in a similar way.
>
> Why doesn't `cp -pR` work the way I expected? Is this a bug with
> cp (we are running OSF1 v3.2 214) or is it supposed to work this way?
Ian Mortimer
Department of Physics Tel : +61 7 3365 3416
University of Queensland Email: mortimer_at_physics.uq.edu.au
St. Lucia, Brisbane Fax : +61 7 3365 1242
Queensland, Australia. 4072.
Disclaimer: Any opinions expressed are my own and do not represent those
of the University of Queensland or the Department of Physics.
Received on Wed Jun 26 1996 - 04:23:20 NZST