[olug] Unix Tip: MOVING FILES WITH CPIO

Matthew G. Marsh mgm at midwestlinux.com
Mon Apr 14 14:00:36 UTC 2003


On Mon, 7 Apr 2003, Brian Wiese wrote:

> Whats the big purpose with using cpio, why not just "cp -xpvr /old /new"?

The only reason would be to not dereference symlinks. cp will deref the
symlink and you end up with several copies of the file. Personally I use
tar for this kind of work (dd for partitions) as I can use it regardless
of the locality of the file system.

In fact one of the best IMHO backup techniques that I use is:

ssh someuser at mycriticalserver.com /bin/tar -C / -zc etc/ | tar -zxv

where the someuser has rights to the etc dir (there are ways around
permissions). Works very well although large binaries are best done w/o
compression.

>        -x, --one-file-system
>               stay on this file system
>        -p     same as --preserve=mode,ownership,timestamps
>        -R, -r, --recursive
>               copy directorie
>        -v, --verbose
>               explain what is being dones recursively  ?? necessary?
>
> What does cpio buy you?  Does anyone ever use it? =)
>
> On Mon, 7 Apr 2003 12:16:19 -0700
> Unix Guru Universe <listserv at ugu.com> wrote:
>
> |MOVING FILES WITH CPIO
> |
> |If you have a multitude of
> |files to move from one
> |directory or filesystem to
> |another, here's a one liner:
> |
> |# find /old_directory -depth | cpio -pdmv /new_directory
> |
> |This will move all of the
> |files under the specified
> |old_directory to the
> |new_directory, keeping the
> |same ownership, permissions,
> |and directory structure.
>
>
>   Brian Wiese | bwiese at cotse.com | aim: unolinuxguru
> ------------------------------------------------------
>   GnuPG/PGP key 0xF3220030 | "FREEDOM!" - Braveheart
> ------------------------------------------------------
> This is not about Napster or DVDs. It's about your Freedom.
>   I'll see your DMCA and raise you a First Amendment.
>               http://www.anti-dmca.org
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
>

--------------------------------------------------
Matthew G. Marsh,  President
Paktronix Systems LLC
1506 North 59th Street
Omaha  NE  68104
Phone: (402) 553-2288
Email: mgm at midwestlinux.com
WWW:  http://www.midwestlinux.com
--------------------------------------------------


More information about the OLUG mailing list