Date: Mon, 10 Jan 2005 01:40:21 +0200 From: Giorgos Keramidas <keramida@ceid.upatras.gr> To: freebsd-questions@freebsd.org Subject: Re: Copying directory trees only for new files Message-ID: <20050109234021.GB75804@gothmog.gr> In-Reply-To: <14545951.20050110000835@wanadoo.fr> References: <14545951.20050110000835@wanadoo.fr>
next in thread | previous in thread | raw e-mail | index | archive | help
On 2005-01-10 00:08, Anthony Atkielski <atkielski.anthony@wanadoo.fr> wrote: > What's the safest and most elegant way to copy an entire directory tree > such that only newer files and directories are actually copied? cpio(1) does that by default (to overwrite files in the destination path that are newer with older copies from the source hierarchy, you have to force overwriting with the -u option). You can use it in `pass through' mode to copy entire hierarchies to another place: % gothmog:/tmp$ rm -fr newstuff % gothmog:/tmp$ find oldstuff | xargs ls -ld % drwxrwxr-x 4 giorgos wheel 512 Jan 10 01:34 oldstuff % drwxrwxr-x 3 giorgos wheel 512 Jan 10 01:34 oldstuff/bar % drwxrwxr-x 2 giorgos wheel 512 Jan 10 01:34 oldstuff/bar/baz % -rw-rw-r-- 1 giorgos wheel 12 Jan 10 01:34 oldstuff/bar/baz/kazaam % drwxrwxr-x 3 giorgos wheel 512 Jan 10 01:34 oldstuff/foo % drwxrwxr-x 2 giorgos wheel 512 Jan 10 01:34 oldstuff/foo/bar % -rw-rw-r-- 1 giorgos wheel 12 Jan 10 01:35 oldstuff/foo/bar/xyz % gothmog:/tmp$ cp -Rp oldstuff newstuff % gothmog:/tmp$ touch oldstuff/bar/baz/kazaam % gothmog:/tmp$ ( cd oldstuff ; find . | cpio -p -dmv /tmp/newstuff ) % /tmp/newstuff/./foo % /tmp/newstuff/./foo/bar % cpio: /tmp/newstuff/./foo/bar/xyz not created: newer or same age version exists % /tmp/newstuff/./bar % /tmp/newstuff/./bar/baz % /tmp/newstuff/./bar/baz/kazaam % 1 block % gothmog:/tmp$ Note that foo/bar/xyz is skipped, since it didn't change, but bar/baz/kazaam is copied because it was touched. - Giorgos
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050109234021.GB75804>