Android - Is there a way to backup contents of internal SD, while preserving the file's modification date?

Try using the -a option to copy all file attributes:

adb pull -p -a /sdcard/

(The -p is for progress indication.)


There are several ways you could accomplish that:

  • if you have sufficient free storage available, archiving the contents (zip, tar, whatever other archiver) and then copying the archive file would be a way. Pulling the archive would change the archive file's timestamp, but contents would be preserved as-is, and restored with their original timestamps. This could be done either from a terminal app, or via adb shell. On one device I've checked, tar and gzip are available, and even bzip2. Successfully tested on another one, and adapted to your specifications: tar czf backup.tar.gz /storge/sdcard0 run from a location with sufficient space would create the archive, which you then could pull.
  • you could utilize a sync app like FolderSync, and simply sync all the contents to your computer (via SFTP, Samba/Windows-Share, or any of the other supported protocols). After having formatted the storage, you could sync it back the very same way.
  • if your device supports an external SDCard, you could copy your files over there, which also should preserve timestamps

There might be even other possibilities, but these are the ones coming to my mind first.