I'm having problems with my internal flash storage (namely not being able to create folders in root, which prevents some apps from working, plus periodic unmounts), and I have tried unsuccessfully to run fsck on it, so I figured I would back up my data, format the internal flash storage, and restore. Running adb pull /storge/sdcard0 will, however, replace the files' modification date, which will be an issue with photos, for example, since the Gallery depends on those dates to sort pics. My question is if there is a way to preserve that data.

  • I have managed to do it by creating a tarball with the sdcard contents, formatting, then using the --delay-directory-restore option. – andrepd Jan 20 '14 at 2:40

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.

| improve this answer | |

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

adb pull -p -a /sdcard/

(The -p is for progress indication.)

| improve this answer | |

Over ssh, we can also use rsync with the -a option:

rsync -a /sdcard/ <destination>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.