From c77d0f3b6dce2322bd1618cf0cb50bb33d15d099 Mon Sep 17 00:00:00 2001 From: Evan Sultanik Date: Wed, 24 Jun 2020 08:52:35 -0400 Subject: [PATCH] Preserve file creation and modification times on restore --- cmd/irestore/irestore.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/irestore/irestore.go b/cmd/irestore/irestore.go index cbcbcfa..978a98d 100644 --- a/cmd/irestore/irestore.go +++ b/cmd/irestore/irestore.go @@ -226,6 +226,11 @@ func restore(db *backup.MobileBackup, domain string, dest string) { total += n r.Close() w.Close() + err = os.Chtimes(outPath, time.Unix(int64(rec.Atime), 0), time.Unix(int64(rec.Mtime), 0)) + if err != nil { + log.Println("error setting the last modification times for file", rec, err) + // this is a non-fatal error, so no need to `continue` + } } } }