Please would you read the following to see the PARTICULAR SITUATION that myquestion relates to. Thanks.1. I'm using the find command to find files that are newer than a given date,then copying those files (ALONG WITH their original path) to an empty directory(called say /park). I want to PRESERVE all the attributes of the DIRECTORIESthat are in the path of the found files, especially the modification date andtime.So far, I've tried cp and cpio (separately) to copy the found files to the emptydirectory, but neither of the commands preserve the attributes of theDIRECTORIES.To be specific, I've only looked at the modification date and time of the copieddirectories (and see that these aren't preserved). I haven't actually looked atthe other attributes.The cp and cpio commands I've used are$ find ... -exec cp --preserve=all --parents -t /park {} \+and$ find ... | cpio -p -dmv /park/See Full Details under 1. for a typical path and filename that I copy to theempty directory (/park).2. So then I tried tar, but (surprisingly to me) that STILL DOESN'T preserve theattributes of the DIRECTORIES.The commands I used are as follows (see Full Details under 2. for fullexplanation):$ cd /park$ find (options that find the files I want) | tar -cvp -T - | tar -xvpf -In a nutshell, the above takes each file found by find, and copies it (alongwith its full original path) into the current working directory (/park).The whole process works, BUT despite using -p, the DIRECTORIES below thedestination directory (/park) do not retain the attributes* of the originaldirectories. (*Not date and time at any rate).The directories are given today's date and time.Main QuestionCould you tell me HOW to preserve the DIRECTORY attributes please, even if it means using a different command to tar?If your kind suggestion is to use rsync, could I humbly ask if you could explainexactly what rsync and its options are doing please. You see, I'm not looking todo any file synchronising.Also, when I've seen rsync suggested for various things, the user uses ablizzard of options, and I end up thinking Is this going to do something Idon't want, or worse, something that I DEFINITELY don't want? Thanks.Full Details1. Typical files that find finds, might be .../etc/timidity/timidity.cfg, or/home/steve/notes.txt.Say my empty (recipient) directory is /park. Then if a found file is/home/steve/notes.txt,it will be copied to/park/home/steve/notes.txtAnd in that path, I want the directories .../home and .../home/steve tohave the same attributes as the originals.2. Full explanation of the tar commands I useNamely$ cd /park$ find (options that find the files I want) | tar -cvp -T - | tar -xvpf -A typical file that find would pass to the pipe, might be/etc/timidity/timidity.cfgThe construction of the command line, and the tar options, might look exotic,but in plain English, the 1st tar creates an archive and receives from find,the names of the files* to archive. (*With their full path). (I'm not sure ifthe -p in the first tar is needed).The archive is then passed to the 2nd tar, which extracts it, and places thefiles in the current working directory (in this case /park), along with theirfull original path.I don't actually create a single-file tar archive, but use tar to create thenimmediately extract an archive. I use this technique so that I can produce FULL PATHS of the source files in the destination directory. BUT ALSO, Ispecifically used tar because I believed that, by definition, it would PRESERVEthe attributes of the DIRECTORIES.I spent a long time working out how to get both tars to use stdin and stdout,and thereby create the required flow of data.
How do I preserve all attributes of DIRECTORIES in path (especially the date and time) when archiving and restoring files?
permissions