find: Archiving
1
1 9.2 Archiving
1 =============
1
1 You can pass a list of files produced by 'find' to a file archiving
1 program. GNU 'tar' and 'cpio' can both read lists of file names from
1 the standard input - either delimited by nulls (the safe way) or by
1 blanks (the lazy, risky default way). To use null-delimited names, give
1 them the '--null' option. You can store a file archive in a file, write
1 it on a tape, or send it over a network to extract on another machine.
1
1 One common use of 'find' to archive files is to send a list of the
1 files in a directory tree to 'cpio'. Use '-depth' so if a directory
1 does not have write permission for its owner, its contents can still be
1 restored from the archive since the directory's permissions are restored
1 after its contents. Here is an example of doing this using 'cpio'; you
1 could use a more complex 'find' expression to archive only certain
1 files.
1
1 find . -depth -print0 |
1 cpio --create --null --format=crc --file=/dev/nrst0
1
1 You could restore that archive using this command:
1
1 cpio --extract --null --make-dir --unconditional \
1 --preserve --file=/dev/nrst0
1
1 Here are the commands to do the same things using 'tar':
1
1 find . -depth -print0 |
1 tar --create --null --files-from=- --file=/dev/nrst0
1
1 tar --extract --null --preserve-perm --same-owner \
1 --file=/dev/nrst0
1
1 Here is an example of copying a directory from one machine to
1 another:
1
1 find . -depth -print0 | cpio -0o -Hnewc |
1 rsh OTHER-MACHINE "cd `pwd` && cpio -i0dum"
1