Settings file times only
Matthias Schniedermeyer
ms at citd.de
Wed Apr 11 16:44:15 MDT 2012
On 11.04.2012 11:14, James Moe wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hello,
> I restored a filesystem by using rsync to copy directories and files
> from a backup volume to the newly recreated volume. All of the
> re-created files were given the current date and time rather than the
> original file's timestamp. I am sure there was a way to prevent that
> from happening.
> Is there a way to use rsync to set the timestamps of the
> destination's file (and directories) to the source's timestamps? I do
> not wish to copy any files. All that needs to match is the filename,
> new or deleted files are ignored.
I think the easiest thing to do is a little shell-magic.
I'll assume local storage
A shell-script:
- /tmp/touch.sh -
#!/bin/bash
BACKUP_DIR='<backup_dir>'
if [ -s $BACKUP_DIR/"$1" ]
then
touch -r $BACKUP_DIR/"$1" "$1"
fi
- snip -
The from the root of your target-directory
find * -type f -exec /tmp/touch.sh {} \;
This calls the script for each file found in the target directory and
sets the mtime for each file that is also in the backup-directory.
The Script is untested.
Depending on how many files there are it may take some time, as this is
basically a fork-bomb.
Bis denn
--
Real Programmers consider "what you see is what you get" to be just as
bad a concept in Text Editors as it is in women. No, the Real Programmer
wants a "you asked for it, you got it" text editor -- complicated,
cryptic, powerful, unforgiving, dangerous.
More information about the rsync
mailing list