cp versus cpio

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: der.hans
Date:  
Subject: cp versus cpio
Am 23. Oct, 2003 schw=E4tzte Jeremy C. Reed so:

> On Thu, 23 Oct 2003, Lynn David Newton wrote:
>
> > Does anyonw have any particular insight into the
> > advangages/disadvantages of using cp -R versus cpio?
>
> cpio is useful because it can be piped over a ssh connection.


Good point that tar and cpio work well for that. I would prefer cpio over a
pipe if it would preserve the directory timestamps.

> I also like -d (--make-directories) for creating leading directories as
> needed.
>
> As for access time, GNU cpio 2.5 has:
>        -a, --reset-access-time
>               Reset the access times of files after reading them, so that=

it
>               does not look like they have just been read.


I'm not really concerned with preserving access-time, but I want to preserv=
e
timestamps on the new directories. The problem is that the tools create the
dirs and then add the files to the dirs. The latter step causes the dir
timestamp to be updated. I want options that'll go reset the timestamp.

       -m, --preserve-modification-time
              Retain previous file modification times when creating files.


lufthans@lufthans:~$ mkdir -p tmp/fred/cpio tmp/fred/cp tmp/fred/tar
tmp/fred/cpioa
lufthans@lufthans:~$ find logs/ | cpio -pdm tmp/fred/cpio/
80 blocks
lufthans@lufthans:~$ cp -pr logs/ tmp/fred/cp
lufthans@lufthans:~$ tar clf - logs/ | tar x --atime-preserve -pf - -C
tmp/fred/tar/
lufthans@lufthans:~$ find logs/ | cpio -pdma tmp/fred/cpioa/
80 blocks
lufthans@lufthans:~$ ls -ld logs/ tmp/fred/*/*
drwxr-xr-x    4 lufthans users        4096 Oct 24 12:42 logs/
drwxr-xr-x    4 lufthans users        4096 Oct 24 12:42 tmp/fred/cp/logs
drwxr-xr-x    4 lufthans users        4096 Oct 24 13:27 tmp/fred/cpio/logs
drwxr-xr-x    4 lufthans users        4096 Oct 24 13:27 tmp/fred/cpioa/logs
drwxr-xr-x    4 lufthans users        4096 Oct 24 12:42 tmp/fred/tar/logs


Hmmm. cp preserved the directory timestamp as well.

ciao,

der.hans
--=20
#  https://www.LuftHans.com/    http://www.AZOTO.org/
#  I'm not anti-social, I'm pro-individual. - der.hans