Site Sponsors:
Backup & Restore Dates & Times under Linux 
Here are two single-line scripts to save + restore the date & times of files + directories under Linux:

Save:

find / -mount -print0 | perl -ne 'INIT{ $/ = "\0"; use File::stat;} chomp; my $s = stat($_); next unless $s; print $s->ctime . "/" . $s->mtime . "/" . $s->atime ."/$_\0"; ' > dates.dat


Restore:

cat dates.dat |  perl -ne 'INIT{ $/ = "\0";} chomp; m!^([0-9]+)/([0-9]+)/([0-9]+)/(.*)!s or next; my ($ct, $mt, $at, $f) = ($1, $2, $3, $4); utime $at, $mt, $f;'


I did not write them - got them from somewhere else - but I used them today. They worked great: We use them to save + restore the dates & times from a backup over to a server where a few gig of files were intermixed.

Wanted to keep it here for future use!

Comments

Add Comment
Comments are not available for this entry.