[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Moving Debian from one HD to another



Zachary DeAquila wrote:
> 
> >Martin Str|mberg wrote:
> >
> >> Just wanted to warn you that cp copies symbolic links as real files.
> >> Thus if you had:
> >>
> >> -rw-r-----   1 ms318    erisoft        4 Apr 11 11:07 jjj
> >> lrwxrwxrwx   1 ms318    erisoft        3 Apr 11 11:07 kkk -> jjj
> >>
> >> in old and did "cp -r old new/" you would get
> >>
> >> -rw-r-----   1 ms318    erisoft        4 Apr 11 11:07 jjj
> >> -rw-r-----   1 ms318    erisoft        4 Apr 11 11:07 kkk
> >>
> >Oops.  Another gotcha.  Is there a flag to cp to preserve links as
> >links?  The disadvantage of making a beeg tarfile is that it will take
> >up a lot of room, so you need to have 3x(distribution size) available to
> >do it that way.
> 
> as root, you want to move /old to /new:
> 
> cd /old
> tar -cvf - . |(cd /new; tar -xvf - )
> 
> that makes a tarfile in a pipe so it doesn't have to sit on disk...
> 
>  --Zachary

...or with GNU tar, and a small sanity check:

(cd /old && tar cfS - .) | (cd /new && tar xvfp -)

That way, if either "/old" or "/new" don't exist, the copy stops
immediately.  If you type the bit with semicolons a lot, eventually you
may typo, and end up destroying files.



Reply to: