-----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. - -- James Moe moe dot james at sohnen-moe dot com 520.743.3936 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+FyfwACgkQzTcr8Prq0ZNinACfcvU/4wGpX8ApKKblxe5jlIf8 cVoAoJAD1VQR7kH+GOfwh9nDgtvxt3MR =y0QD -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 - --times --size-only --itemize-changes check it out first with --dry-run On 04/11/12 14:14, James Moe wrote:> 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. >- -- ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~ Kevin Korb Phone: (407) 252-6853 Systems Administrator Internet: FutureQuest, Inc. Kevin at FutureQuest.net (work) Orlando, Florida kmk at sanitarium.net (personal) Web page: http://www.sanitarium.net/ PGP public key available on web site. ~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~'`^`'~*-,._.,-*~ -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.17 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+FymUACgkQVKC1jlbQAQeqZwCgkF2FZyk9pm840uGvUrVVuk9B KHEAoNSQdgoRxAqyzwF9DQ7t46SIXU/9 =XOUT -----END PGP SIGNATURE-----
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 04/11/2012 01:53 PM, Kevin Korb wrote:> It shouldn't care which way the time stamps are off. --times > (which is part of --archive) will tell rsync to correct the time > stamps and --size-only tells rsync to assume that files of the same > size are actually the same content. > > In fact the man page entry for --size-only suggests using it for > this situation. >Here is the result: rsync --times --size-only --itemize-changes --dry-run \ /media/backup05 /LocalBackup/pub-data/tmp3/ /t/tmp3/ skipping directory . That is it. Obviously rsync found nothing to do. The rsync man page indicates "--size-only" (skip files that match in size) skips files that have the same size, ignoring the timestamp. Almost all of the target files have the same size since all that has changed is the timestamp, which I wish to restore on the destination. I also tried the "--ignore-times" option (don't skip files that match size and time) option with no noticeable change in behavior: rsync --times --ignore-times --itemize-changes --dry-run \ /media/backup05/LocalBackup/pub-data/tmp3/ /t/tmp3/ skipping directory .> On 04/11/12 16:50, James Moe wrote: >>> --times --size-only --itemize-changes > >> That did not work. I am hoping for a way to change the times on >> files where the timestamp is *later* than the source timestamp. >- -- James Moe moe dot james at sohnen-moe dot com 520.743.3936 -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.18 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk+F8kwACgkQzTcr8Prq0ZOPOACfYaEGA7OmQF27CwSVXT9HTMhc oW0AnignIXOZtruGSmqttihW2wmHLUuE =AeOC -----END PGP SIGNATURE-----
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.