Copy Files to Android While Preserving Timestamp

Recently I bought a Google Pixel XL and tried to copy files to it. I found that the timestamp of the copied files is the time of the creation of the copy, not last modified date in original filesystem. After some googling [1], I found that the only solution to the earlier version of Android is rooting the Android devices.

Luckily enough, The Google Pixel XL can run Android 10 and it is possible to use adb push to keep timestamp because the filesystem is changed from FUSE to SDCardFS.

On Ubuntu system, it is easy to install adb: [3]

$ sudo apt-get install android-tools-adb android-tools-fastboot

Enable USB Debugging on Google Pixel XL [4]. Open a terminal and use USB cable to connect your phone and Ubuntu machine. Allow USB debugging on your phone, in the Ubuntu terminal, we can see the Android device by:

$ adb devices

You can see your phone in the list. Push the files to Android phone by:

$ adb push myfolder /sdcard/Download

After pushing files finished, we can use adb shell to check the files on Android phone:

# Login to Android shell
$ adb shell
# Go to the Download folder
$ cd /sdcard/Download
# See the timestamp of files
$ ls -al

If you are running Android 10 on Google Pixel XL, you can see the timestamp of files is preserved after the push!

Hope this helps those who have the same issue as me.

Tested on: Ubuntu Linux 20.04.


[3]How to Install ADB on Windows, macOS, and Linux
[4]How to Enable USB Debugging on Google Pixel or Pixel XL (Android 7.0)
[5]failed to authenticate to <ip> | adb wifi - Stack Overflow