Menu

How to use this script ?

An mac
3 days ago
2 days ago
  • An mac

    An mac - 3 days ago

    How do I use this ? I have a pixel 9 pro and as well as galaxy s8 that I want to preserve timestamps when making backups or copying files and folders from android to PC exactly 1:1 copy. How can I do this with this script ?

    Thanks

     
  • dragomerlin

    dragomerlin - 2 days ago

    If you just want to backups files inside the internal sdcard or external sdcard (microsd), I recommend you to use the app RAR from the Play Store. And save in .rar format compression level can be set to lowest (store). It will allow you to keep the last modification time of all files, called also "mtime" or "Modify". You cannot save the creation/Birth time "btime" or "crtime" since Android even doesn't care about that (and usually it's not important).

    If you don't have enough space to compress all sdcard into a single rar file, compress less files each time and move the rar files to your computer.

    The rar format stores the mtime with full decimal precision. Also if you extract the rar inside the phone it restores the mtime too.

    If you want, you can do it with adb and pull all the files to your local computer, for example I did this with linux, it preserved the mtime and does the pull recursively, but rounds the mtime to whole seconds, does not has the 0.0000001 second precision that rar has:

    adb pull -a -p  /sdcard/  ./sdcard_backup/
    

    To restore with mtime and recursively:

    adb pull -a -p  somefile.txt  ./sdcard/
    

    Watch for any timeout or error, try pulling individual folders if that happens. Note that if you are not root, you won't be able to pull some protected directories or apps' data, but maybe you already knew. For apps you have to use the Google cloud backup (Google One) and check in the new device if there's what you need, the "adb backup" is not really functional nowadays.

    The last solution is to connect the phone to the computer, but instead of using "adb pull", use the MTP protocol. The MTP / PTP protocols does not work well, they hide certain files and have unreasonable timeouts, among other things. Also it doesn't work well preserving timestamps.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.