I used an adb command to backup a file in data/data of an Android phone. After the command ran, my phone said it was successfully backed up, but where is the backup file?
If you use adb backup -all command then it will create backup.ab file in the current working directory.
If you want to specify path use -f like below
adb backup -f <path_to_backup_file> -all
So if you run
adb backup -noapk com.masimo.merlin.consumer
then backup.ab gets stored in the present working directory by default.
In unix/linux, you can know your present working directory by typing pwd and in windows you can know it by typing cd
More Info about backup
Related
I'm trying to use the Android Adb Command Prompt to copy a folder inside the app container to a local Windows folder. The device is running Android 5.1.1 and is not rooted.
adb pull or cp aren't working. How can I copy a folder?
The following approaches aren't working:
Approach 1
adb shell
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
error: device not found
Inside the shell you can't see to do adb pull. See here.
Approach 2
DDMS can't access the data folder.
Approach 3
adb shell
run-as DroidSample.DroidSample
cp /files/MetroLog/MetroLogs/ C:/temp/test
cp: /files/MetroLog/MetroLogs/: No such file or directory
Approach 4
adb shell
run-as DroidSample.DroidSample
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs/ C:/temp/test
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs is a directory (not copied).
This is also not working.
Approach 5
adb shell
run-as DroidSample.DroidSample
chmod 777 /files/MetroLog/MetroLogs
exit
exit
adb pull /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs C:/temp/test
adb shell run-as DroidSample.DroidSample
chmod 700 /files/MetroLog/Metrologs
remote object '/data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs' does not exist
So also this isn't working.
Approach 6
adb shell
mkdir /sdcard/tmp
cp /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs /sdcard/tmp
cp: /data/data/DroidSample.DroidSample/files/MetroLog/MetroLogs: Permission denied
This is also not working.
Approach 7
The only thing which half work is this
adb exec-out run-as DroidSample.DroidSample cat "files/MetroLog/MetroLogs/Log - 20160509.log" > C:/temp/test/test.log
But here I don't get the original file and I also have to know the exact file name. Additionally, that I loose line breaks and I have to do this for each file. Not that what I want.
So I'm running out of ideas. How can I access the internal stored files and copy them over?
You have almost solved the problem. As the storage of this kind is secured, you need to do one additional step. You need to copy the file from secured location to sdcard of the device. And then you can copy it anywhere via usb or android pull. Here are the command sequence I executed successfully.
adb shell
run-as DroidSample.DroidSample
cd shared_prefs
cp DroidSample.DroidSample_preferences.xml /sdcard/DroidSample.DroidSample_preferences.xml
exit
exit
adb pull /sdcard/DroidSample.DroidSample_preferences.xml C:/test/
That's it.
And I really appreciate the way you posted your question. Best of luck.
You're trying to gain read access to /data partition on actual android device. Such thing is not possible without root access, even if the app folder is yours. For the reason that permissions to read /data partition are not granted and cannot be granted, unless you're using an emulator. On emulator, which by default is with admin privileges for developer, you can access the data partition to read and write. On actual device you cannot. Not with adb, not with DDMS.
So basically speaking, anything that requires access to those files under /data is not going to work. Whether you sue cp command or pull command. The moment your kernel reads the beginning of your path which starts with /data/... it says: Oops, no can do.
You are trying to access /data folder of android device which is not accessible in unrooted device.
I am using a MacBook as my development machine. My Android phone is not rooted. I want to copy my Android app's file from phone to my MacBook. I tried the following:
Connect Android phone to MacBook (Developer's option is enabled)
adb pull /data/data/com.my.app/app_data/data ~/Documents/my/app/
where /data/data/com.my.app/app_data/data is the file path on phone, and ~/Documents/my/app/ is the directory path on MacBook.
But the above adb pull command shows Permission denied.
I also tried to use su under adb shell, but it doesn't work either:
~$ adb shell
shell#xyz:/ $ su
/system/bin/sh: su: not found
So, how can I copy my app's internal file to my MacBook directory?
On a non-rooted phone you can not access the app private data directory (/data/data/com.my.app).
The only way to extract the data is to create a backup of the app data using adb backupp:
adb backup -f mybackup.ab com.my.app
For extracting the information from the created backup archive you can use the Android Backup Extractor. It converts the Android backup archive to a tar archive file.
Note: If the app specifies in it's manifest that backup is disallowed the described way does not work. In such a case the only way is to root the phone.
You have to navigate to your file with adb shell.
Then copy to sdcard:
cat yourfile > /sdcard/yourfile
Then exit from adb shell and now you can pull:
adb pull /sdcard/yourfile
I'm trying to install valgrind on my android device, but when i try to execute adb push Inst /
i get an error
C:\VmFiles>adb push Inst /
push: Inst/data/local/Inst/bin/vgdb -> /data/local/Inst/bin/vgdb
failed to copy 'Inst/data/local/Inst/bin/vgdb' to '/data/local/Inst/bin/vgdb': N
o such file or directory
Ofc file vgdb exists in this directory
C:\VmFiles>ls Inst/data/local/Inst/bin
callgrind_annotate cg_diff valgrind vgdb
callgrind_control cg_merge valgrind-di-server
cg_annotate ms_print valgrind-listener
after some observation i found there is no directory Inst/bin in local
so first you need to make a directory in /data/local/Inst/bin
and for that you need root access to your device because you cant access /data/ directory without root permissions
then do following steps.
first go to directory where vgdb is placed then
execute
adb push vgdb /data/local/Inst/bin/
Syntax for adb push :
adb push <PATH_OF_FILE_ON_HOST> <PATH_OF_FILE_ON_DEVICE>`
Since you are trying to push from Inst/data/local/Inst/bin/ path. Use the below command with absolute path.
adb push /full/path/to/Inst/data/local/Inst/bin/ /path/on/device/test_folder/
This should push all (both files and directory) content of the directory Inst/data/local/Inst/bin/ to /path/on/device/test_folder/
Make sure /path/on/device/test_folder/ exist, or run below command before hand.
adb shell mkdir /path/on/device/test_folder/
Use adb shell ls /path/on/device/test_folder/ to list, if your files are transferred to the device.
Also make sure you have permission to write to /path/on/device/test_folder
Note: You will usually have permission to write to /sdcard/ but again will require root permission to assign execute permission (chmod) to the transferred binary.
In this case, may need to root the device.
I am trying to reach the sqlite database on my device using the procedure described here: How can i see SQLite Database (No emulator)?
However, I keep on getting sqlite3 not found.
I assume I am meant to be entering the commands with the hash (#) sign at the start of the line.
I tried with it and got nothing.
Without it I get the error message.
The sqlite3.exe file is definitely there and in the path.
Do I have to install something?
Some manufacturers deliver the devices without sqlite being installed on them. You can copy the sqlite program though from a emulator to your device if the device has an arm processor.
Start the emulator and use the adb command from the platform-tools in android-sdk
adb pull /system/xbin/sqlite3
Mount the system partition of your device read/write after this tutorial:
http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html
Use the adb command to copy the sqlite3 file to your device
adb push sqlite3 /system/xbin/
After you reboot your device the sqlite3 command should work.
Edit (copy from linked page - in the case link becomes invalid). The instructions for step 2 are:
adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
"Replace /dev/block/mtdblock3 & /system with appropriate device path and mount point, as obtained from cat /proc/mounts"
Go to Play store --> search for Titanium Backup & install it
adb shell
su
cp /data/data/com.keramidas.TitaniumBackup/files/sqlite3 /system/xbin/
cd /system/xbin/
chmod 755 sqlite3
adbd reboot (just in case)
Enjoy the result
For those who, like me, couldn't use Sqlite3, I used a workaround for this:
cat srcfile> / mnt / sdcard / dstfile
With this you can put the files into an external .db manager.
I am trying to reach the sqlite database on my device using the procedure described here: How can i see SQLite Database (No emulator)?
However, I keep on getting sqlite3 not found.
I assume I am meant to be entering the commands with the hash (#) sign at the start of the line.
I tried with it and got nothing.
Without it I get the error message.
The sqlite3.exe file is definitely there and in the path.
Do I have to install something?
Some manufacturers deliver the devices without sqlite being installed on them. You can copy the sqlite program though from a emulator to your device if the device has an arm processor.
Start the emulator and use the adb command from the platform-tools in android-sdk
adb pull /system/xbin/sqlite3
Mount the system partition of your device read/write after this tutorial:
http://android-tricks.blogspot.com/2009/01/mount-filesystem-read-write.html
Use the adb command to copy the sqlite3 file to your device
adb push sqlite3 /system/xbin/
After you reboot your device the sqlite3 command should work.
Edit (copy from linked page - in the case link becomes invalid). The instructions for step 2 are:
adb shell
su
mount -o rw,remount -t yaffs2 /dev/block/mtdblock3 /system
"Replace /dev/block/mtdblock3 & /system with appropriate device path and mount point, as obtained from cat /proc/mounts"
Go to Play store --> search for Titanium Backup & install it
adb shell
su
cp /data/data/com.keramidas.TitaniumBackup/files/sqlite3 /system/xbin/
cd /system/xbin/
chmod 755 sqlite3
adbd reboot (just in case)
Enjoy the result
For those who, like me, couldn't use Sqlite3, I used a workaround for this:
cat srcfile> / mnt / sdcard / dstfile
With this you can put the files into an external .db manager.