Skip to main content

Copying Files - Preserving Attributes

One way to do this is:

Supposedly, the following will work to copy a file (or group of files) from a directory and preserve the attributes (ownership and permissions).

$ cd /path/to/source/dir

$ find . | cpio -pdumv /path/to/destination/dir

The cpio command is a copy command designed to copy files into and out of a cpio or tar archive, automatically preserving permissions, times, and ownership of files and subdirectories.

An alternative is to use the -p option on the cp command.

The -p option of the cp command can be used to preserve attributes.

See cp --help or man cp for further details.

Of course, don't forget to add the -r on as well, so it copies all files / directories recursively. So you'd use something like:

cp -rp /home/timbruce/data/ /media/backupdrive/timsdata/