How to preserve all timestamps while copying files
I need to copy a directory from one place to another. I want all the files, both in the source and the destination, to have the Access, Modify, and Change timestamps they had before I began the copy. I've found that cp, rsync, and tar each offer options that preserve some of the timestamps, but I can't find a way to preserve all of them. Doing a disk image copy is not an option. The directory has 3 million files spread out over tens of thousands of subdirectories going 20 levels deep, so anything that handles files individually is not practical. Does anyone know of a solution?
|
Quote:
rsync -a sounds to do what you want. If that looks like it'll be too slow, then I'd say just dd the source device to the target device. why is that not an option? |
Both directories are about 200 GB within a multi-terabyte filesystem, so dd won't work.
I've tried rsync -a. It leaves the timestamps on the source files unchanged, but updates the Access and Change timestamps on the destination. |
You can preserve the access and modify time, but not the change time, since whenever you copy a file a new inode is created.
|
Quote:
|
Quote:
Code:
<commands> | cpio -p --reset-access-time --preserve-modification-time /path/to/dest/dir |
Using tar to replicate preserves the mtime and atime:
Code:
> tar -C work/ -cf - home.png | ssh hpmedia 'tar -C rsynctest -xvf - home.png' |
Quote:
|
You are right, I should have included the --atime-preserve option.
|
Quote:
|
Just out of curiosity, why are you so concerned about change time? It is related to the inode and it is transparent to many commands, which on the contrary refer to the modification and/or the access time to work properly.
|
Dump and Restore?
I believe Dump and Restore will preserve all timestamps.
Ivan. |
"rsync -a" too.
|
All times are GMT -5. The time now is 07:18 AM. |