[Question][ADB] How to "adb push" with timestamps like "adb pull -a" - Android Q&A, Help & Troubleshooting

[Question][ADB] How to "adb push" with timestamps like "adb pull -a"
Hello, as said in the title of the post, I need to push photos to my phone but with their original timestamps. I backupped my internal storage with the command
Code:
adb pull -a -p /sdcard "PC_directory"
But I need a command to re-transfer everything back to my phone. I'd like to do this, because othewise, all the photos in my gallery will be set to the actual phone's date. Is there a way to do that? Thank you in advance!

Would also like to know if there is a solution to transfer files via adb while preserving timestamps.

You may use dd command to do a 1:1 ( bitwise ) copy of data / files - requires the source data / files are housed in an .IMG-file.

I believe you can achieve it by creating an archive with tar and output it to stdout. Then pipe it to adb exec-in with a tar command to extract it on the phone.
Update: tested it out and it seems that exec-in outputs to a file and you need to create an intermediate archive on the receiving device.

Related

[Q]adb commands

I know the basic commands but I was wondering if I were to do
Adb pull /sdcard....
What command line would be needed for me to direct the contents to a folder in my adb/tools folder on my pc? I tried /sdcard backup (open folder) but it would not let me do so.
Also any great place to find a list or material for adb & busybox commands?

[Tutorial] x10mini Linux helpers

Hello
Like some other guys i use linux on my PC. If you want to change your x10mini via shell you can do it but its not very confortable.
I made a few tools so it's easier to use.
Note: This "tricks" are only usefol to you if you are a little advanced with linux and want to "work" with your x10i via shell. I tested it all on a Debian 64bit but think most parts are universal.
1. Putting adb to /etc/bin
First of all you should put the adb-binary in /etc/bin/ so you can access it like every other cmd. You can use the binary in my attached tar or the one from SDK. use "sudo cp adb /system/bin/adb" (if you have a system with sudo, eg debian & ubuntu)
2. adb: error insufficient permissions for device
If you plug in the phone and want to connect via "adb shell" it may says that you don't have permissions for device. There is a workaround:
- Create file /etc/udev/rules.d/51-android.rules
- Put the following in the file:
Code:
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0fce", ATTRS{idProduct}=="2137", MODE="0666"
- restart udev "sudo service udev restart" (again this is debian&ubuntu-only)
if you still got "insufficient permissions", i made a little shell-script "adb-fix-permissions" attached in tar-file
3. bash-completition for adb
Bash is really annoying whitout completion. That means you can just start to type a word, then press [tab] and bash complets it for you. For example you type "adb ki[tab]" and bash complets it to "adb kill server"
To get this you need "adb_completition" from my attached zip or from here. Put this file in /etc/bash_completion.d/ and you got it.
example command to copy it:
"sudo cp adb_completition /etc/bash_completion.d/adb_completition"
4. Some keys not work in adb shell
This is a known and annoying bug. Eg in nano text editor you cant use the [enter]-key. There is a (little unclean) workaround for it: start a telnet-service on the phone, forward ports via adb and connetc to your phone via telnet. You will need telnetd from the attached tar. And your phone needs to be rooted.
- Remount system writable:
Code:
adb remount
- Put telnetd on your phone
Code:
adb push telnetd /system/bin/telnetd
- Make it executable:
Code:
adb shell chmod +x /system/bin/telnetd
for usage i have a little made a little script (in attached tar) "adb-shell".
Or you can do it manual:
Code:
adb telnetd &
adb forward tcp:9999 tcp:23
telnet localhost 9999
.. to be continued...
if you have one, please share your linux-android-tricks with me
thanks

USB transfer workaround

For the past couple of days I have issues with transferring files over usb as no support is built into to the ics kernel for the usb transfer unless a physical sdcard is detected. I tried the mtp, thing and for some reason that wont show the files. Here is what I found that works best for transferring files rather than installing sketchy Chinese programs.
Note all commands are in quotes, do not type the quotes
Setting up and checking files in directories​
1. Install androidsdk
2. open a command prompt and cd to where your adb tools are. They are typically in C:\android-sdk-windows\platform-tools
3. "cd C:\android-sdk-windows\platform-tools" after you download the pack through the platform tools pack through the sdk manager. Yours may be in a different place depending on install. If you have set the system variable for adb skip to step 4.
4. Set your touchpad to go into android debugging mode when plugged in, under developers options
5. Type in "adb devices" to make sure your touchpad is seen by computer
6. Now access your devices by typing "adb shell" (if you have the ghost emulator 5554, use adb -d shell)
7. From there type "cd /sdcard/"
8. Type "ls" to receive a list of all files on your touchpad (note l is an L)
9. From there simply use the cd command to get in and out of directories
Transferring Files​
When you want to transfer files to and from the touchpad, open a new command prompt and get back to the location with your adb files.
To copy to touchpad
Use the adb push command, example of adb push:
"adb push C:\users\stephen\downloads\example.apk /sdcard/"
The format is adb push local directory to remote directory.
To pull from touchpad
To pull something from your touchpad use adb pull command. The format is adb pull remote directory to local directory.
Example: "adb pull /sdcard/getjar.apk c:\users\stephen\desktop"
I installed DroidSSHd for root GUI. and for GUI file transfer/install I use AirDriod.
edit: course, all this is done on the air.

[GUIDE][TUTORIAL][SHARE] How to make a nandroid backup directly to your computer with

Note: I'm just sharing the work of the XDA member.This guide was tested on Galaxy Y GT-S5360.Here's a little introduction:
scandiun said:
INFORMATION
This guide is intended to make a full backup of your android phone (the entire memory block with all partitions) or a single partition (including sdcards, etc) directly to your computer, in either
Block level (with dd): for single partitions or whole memory block (all partitions in one piece). The backup always has the same size which is the size of the partition.
File level (with tar): only for individual partitions. This only includes files and folders, so occupies much less space, depending on how much filled is the partition.
It can be done with the phone powered on or from ClockWorkMod Recovery (from both ADB works, while in Fastboot doesn't so won't apply). Unless specified the commands meant to be used from Windows. For Linux and Unix is similar.
REQUIREMENTS
Rooted Android Phone
Busybox installed on your phone
If you are using Linux / OS X you have native tools, for Windows download Cygwin, and install with it netcat, pv and util-linux. Get them from Cygwin's setup.exe
ADB installed.
Make sure adb.exe is in your windows' path. See here and here, or use Path Manager.
Android phone with USB Debugging enabled, and the proper drivers installed on Windows so the phone is recognized. Typing 'adb devices' on a terminal should show your device.
PARTITION IDENTIFICATION
You now have to identify the partition or block device that you want to backup. For a single partition you can use either tar or dd, while for the entire memory block you can only use dd.
For example, on Galaxy Nexus you have the list of partitions here and for Galaxy S2 here.
Usually on android, the entire block containing all partitions is located at /dev/block/mmcblk0 and the data partitions is a subpartition of it. You can push parted with GPT support to your device and see all information on a partition or block.
Whole phone memory -> /dev/block/mmcblk0 (may vary, in some phones this is the sdcard)
Subpartitions -> depends on each device. Usually at /dev/block/platform/dw_mmc/by-name/ there are listed by name linking to the real device.
Back up of the whole memory block (via adb)
Connect the phone in ADB mode and unlock the screen.
Open one Cygwin Terminal and enter (replace mmcblk0 if needed):
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox dd if=/dev/block/mmcblk0
You will see the cursor blinking at the left. Now the phone is waiting to send the block over the network.
Open another Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > mmcblk0.raw
You will see how the image size is growing until it finishes. Now you have the whole phone backed up in raw format. You can see the contents of the GPT partition with gptfdisk tool, available for windows, linux and such. See official website and sourceforge to get it. You can do it the same from ClockWorkMod Recovery but you have to mount first the /system partition since the busybox included with clockworkmod does not come with netcat and you have to use the one from the system partition.
With further linux tools you could edit or extract single partitions from the whole block.
You can use adb via wifi as well with applications like WiFi ADB.
Back up of the whole memory block (via wifi)
Original post: [Q] Nandroid directly to computer w/o sdcard
We need to install a FTP server on the computer or the other device, configure a user with a password if we want to, and set some port. It uses by default 21 but this example uses 40. We must set a home dir for the user with write permissions.
Usually is a good idea to put myfifo in /cache not in /data because we may overwrite sensitive data in case we want to use that raw image for data recovery.
Open one Cygwin terminal
Code:
adb shell
su
mkfifo /cache/myfifo
ftpput -v -u user -p pass -P 40 COMPUTER_IP block.raw /cache/myfifo
Open another Cygwin terminal
Code:
adb shell
su
dd if=/dev/block/mmcblk0p12 of=/cache/myfifo
Tips:
- Fifos only can be made on linux native filesystems, for example on a FAT partition is not possible.
- Reading from a partition does not modify it.
Now check on Filezilla Server the speed
Back up of the whole memory block (USB tethering, Wifi tethering)
To use tethering you have to disconnect the computer from all networks and connect it only to the phone with the type of connection you want.
Once you connect it, you can view the IP of the computer and the IP of the phone from connection properties. The ip is the computer ip and the gateway is the phone's ip.
Wifi Tethering: Computer Phone Internet
USB Tethering:
Computer Phone Internet
Conputer Phone Internet
This is exactly the same as via wifi, except that the transfer speed is much higher because the computer and the phone are directly connected, instead of using a router as a gateway. In this case, the gateway is the phone. USB tethering has the highest transfer rate.
Back up of a single partition (raw = every bit of the partition)
It is exactly the same as the the previous but replacing mmcblk0 by the corresponding partition. You can use in this particular case several software to read the partition from windows, depending on partition filesystem: DiskInternals Linux Reader, Ext2Read, Ext2 File System Driver for Windows, Ext4Explore, plugin for Total Commander and ImDisk Virtual Disk Driver. You can also use recovery software on individual partitions like Recuva in combination with VHD Tool or command line tools included with operating systems.
Back up of a single partition (tar = only files and folders)
In this case, you need the partition mounted. To see the list of mounted partitions type on Cygwin Terminal
Code:
adb shell mount
Now you need to know where is mounted the partition you want to backup, for example the firmware is mounted on /system, which is the ROM.
In this case you will have to open three terminals, because of android limitations:
Open one Cygwin terminal and create a fifo, in /cache, for example, and redirect the tar there
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox mkfifo /cache/myfifo
/system/xbin/busybox tar -cvf /cache/myfifo /system
We have to do it this way because redirecting the tar to stdout (with - ) is broken on android and will corrupt the tar file.
Open a second Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
adb shell
su
/system/xbin/busybox nc -l -p 5555 -e /system/xbin/busybox cat /cache/myfifo
Open a third Cygwin terminal and type:
Code:
adb forward tcp:5555 tcp:5555
cd /path/to/store/the/backup
nc 127.0.0.1 5555 | pv -i 0.5 > system.tar
You can browse the tar file with Winrar, Total Commander, PeaZip and almost any compression tool. Note that you shouldn't extract files or edit it since the tar format saves the permission and owner data for each file, that is lost when extracted to FAT / NTFS partitions and you will mess things when restoring.
LINKS
[GUIDE] Internal Memory Data Recovery - Yes We Can!
How to Create and Attach a Virtual Hard Disk in Windows 7
[Guide] Types of Android backups
Click to expand...
Click to collapse
Original Thread : http://forum.xda-developers.com/showthread.php?t=1818321
And here is the guide to make nandroid backup through terminal app in android with switching off the phone in sdcard!!!
http://forum.xda-developers.com/showthread.php?t=1620255

[Solved] How to adb pull to any other directory than platform-tools?

Hi there,
The device is rooted.
I tried
Code:
adb pull /dev/block/mmcblk0p43 > /users/wenyuan/desktop/android/43.img
(mmcblk0p43 is userdata partition).
But the command was just stuck there and did not produce any results.
Would it be possible to adb pull partition (ex. userdata) to any other location than under platform-tools directory?
Would it be possible to adb pull partition even to an external disk?
Thanks.
-- Solution for internal disk--
The right code:
Code:
adb pull /dev/block/mmcblk0p43 /users/wenyuan/desktop/android/43.img
Remove ">"
do not use ">" in the command
CXZa said:
do not use ">" in the command
Click to expand...
Click to collapse
Thanks. It worked.
But would it be possible to adb pull a partition to an external disk?
I tried
Code:
adb pull /dev/block/mmcblk0p43 /Untitled/wenyuan/43.img
Untitled being the name of the external hard disk.
It did not work.
it works like this. maybe the external hard disk is not ready. also take care of fat32 file system only accept files < 4gb
if "Untitled" contains whitespaces you must quote path
aIecxs said:
it works like this. maybe the external hard disk is not ready. also take care of fat32 file system only accept files < 4gb
if "Untitled" contains whitespaces you must quote path
Click to expand...
Click to collapse
Given that,
1. in
adb pull /dev/block/mmcblk0p43 /users/wenyuan/desktop/android/43.img,
/users is under Macintosh HD; and
2. "Untitled", as an external hard disk, has the same status as Macintosh HD,
there should be some code indicating the location to "Untitied" hard disk, (ex. cd).
I tried
Code:
adb pull /dev/block/mmcblk0p43 cd /untitled/android/43.img
and it did not work.
type 'adb help' for usage
Code:
device commands:
adb push <local>... <remote>
- copy files/dirs to device
adb pull [-a] <remote>... <local>
- copy files/dirs from device
(-a preserves file timestamp and mode)
cd is cmd to change dir (unrelated to adb), don't invent fantasy usage.
btw "it did not work" is no meaningful error message. I am pretty sure the shell replied with something you can google for...
CXZa said:
do not use ">" in the command
Click to expand...
Click to collapse
Am I right in saying that
">" can not be used in "adb pull" but should be used in "adb shell su" and "adb exec-out", in case of pulling partitions? Or in any other circumstances?
Oh no, adb help and google search were no help.
https://bash.cyberciti.biz/guide/Standard_output
https://www.cyberciti.biz/faq/redirecting-stderr-to-stdout
aIecxs said:
https://bash.cyberciti.biz/guide/Standard_output
https://www.cyberciti.biz/faq/redirecting-stderr-to-stdout
Click to expand...
Click to collapse
Thanks for the links.
But I meant adb help and Google search did not help on how to adb pull device partition directly to an external disk.
refer to post #6
there is only one exact usage for adb pull
Code:
adb pull [-a] <remote>... <local>
where <local> is valid path to any directory on PC (whatever it is)
in case the command failed it will output meaningful error message. search for that error message (or post here)
what else do you expect to know?

Categories

Resources