[GUIDE][Windows] Making backups with adb - Nexus 4 General

NOTE: The Nexus 4 does not have a physical sd card. However, the user directory on the phone is located at /storage/sdcard0/ and will, for the purposes of this guide, be referred to as the sdcard.
Click to expand...
Click to collapse
Making sdcard backups with MTP is often unreliable. First of all, files are not always immediately updated with the ones on your phone. As a result, there may be folders missing, files that you deleted on your phone still showing up, etc. Also, the Date modified values of files are changed to the time that the files were moved onto your computer, which can cause errors when restoring them to your phone; i.e. photos in gallery not appearing in order. Other times, MTP is simply not available (if you have an older computer or an unsupported OS, for example). The best way to go about a backup is by using adb (Android Debug Bridge).
So, let's get started.
1. First, you're going to need some variant of the Android SDK/Software Development Kit as well as the Nexus 4 drivers installed. I won't show you how to do this, as there are already many guides and tutorials available.
Here's the link to the official Google ADT/Android Developer Tools.
2. Once you've got everything on your computer set up, open up the Settings app and go to About phone. Scroll down and quickly tap the Build number tile seven times. You have now enabled Developer options.
Go back, enter Developer options and enable USB debugging. An authorization pop-up will appear; allow it.
3. Now, open up a command prompt window and change directory to the location of adb on your computer. If you installed the official SDK, this will be under
Code:
folderyouextractedto\sdk\platform-tools
Connect your phone via USB and type
Code:
adb devices
You should see something like this:
Code:
List of devices attached
random numbers and letters device
If you don't, you probably don't have the drivers installed properly OR you failed to authorize your computer for USB debugging.
4. Make a folder on C:\ (or whatever your OS drive is) with NO SPACES in the file name. You can now make the backup.
Type
Code:
adb pull /storage/sdcard0/ C:\folderyoumade
You are now backing up your entire sdcard. This can take a while, depending on how many files you have on your phone.
When the copy is complete, you should see something like
Code:
x files pulled. 0 files skipped.
0 files skipped is very important, as it confirms that all of the files were copied over correctly.
To backup specific folders on it, simply change the command to that directory on your phone.
i.e.
Code:
adb pull /storage/sdcard0/folderyouwant/ C:\folderyoumade
5. To restore a backup, simply type
Code:
adb push C:\folderyoumade /storage/sdcard0/
NOTE: Restored folders DO NOT replace existing folders on your sdcard. They are merged (so pre-existing files in a folder remain, while any new files are copied in).
Click to expand...
Click to collapse
NOTE: I recommend that you do not use your phone during a backup or restore so as to make sure all files are properly copied.
Click to expand...
Click to collapse
Remember, this is only an sdcard backup. App and system data are NOT copied over. If you want to make a backup of your app data, the easiest way to do this is with Titanium Backup, Helium, or a similar app and then backup those files using adb pull. If you wish to make a complete backup of your file system (not including sdcard though), make a nandroid from recovery.

Reserved

klvnhng said:
Reserved
Click to expand...
Click to collapse
Good method if MTP failes or crashes! Thanks!

Thanks!

I get remote object '/storage/sdcard0' not a file or directory when I try pull. Help?:crying:

nphone said:
I get remote object '/storage/sdcard0' not a file or directory when I try pull. Help?:crying:
Click to expand...
Click to collapse
You forgot the frontslash at the end of 0. Try that

On some devices you can't specify destiny forlder in order to use adb push or pull, you have to use current folder:
Code:
cd C:\folderyoumade
adb pull /storage/sdcard0/folderyouwant/
It's better to backup the sdcard this way than using adb backup because it also backups the Android folder inside the sdcard.

Or much shorter;
adb pull /sdcard C:\SDCARDBackUp
__________________________________________________
Device: Google Nexus 4 (LG-E960) 16GB (MAKO)
ROM: SimpleAOSP-L-ROM (Stable Build 7)
Kernel: Stuxnet v4.5 (3.4.105)
Gapps: PA-Gapps-5.0.1-BETA4 (MINI)
_________________________________________________

Is there a way for pull to skip files which already exist in your specified destination? Sometimes it errors in the middle of a long transfer because it doesn't like a file name or something.

I was looking for a better way to push my virtual sd card backup, as using the copy and paste method in windows doesn't copy all of the files for some reason. It will copy all the files from the sd card to the PC, but not back again. I was having to search through every folder and copy and paste to get everything copied back. Thank you so much for this tutorial. I knew about adb push command, but I never tried it, because I always thought the copy and paste method would be easier. Boy was I wrong. This way pushes all the files in one try. Soooo much easier.

I have a question, can I also backup this file directory: /storage/emulated/0? Or is this something else, I checked both folder and they seem to be the same.

Hi,
I've done a full backup using adb backup, including the whole content of my sd card (using the -shared option).
However, when restoring my device using adb restore, nothing is restored on my sd card (not the apps and not the files).
Am I doing something wrong?
Is there any special option to use for the restore?
Is there any other way to restore my apps&data from my backup file (.ab) using other commands ?
The content of my backup file seems correct though.
Thanks!

NikoBe00 said:
Hi,
I've done a full backup using adb backup, including the whole content of my sd card (using the -shared option).
However, when restoring my device using adb restore, nothing is restored on my sd card (not the apps and not the files).
Am I doing something wrong?
Is there any special option to use for the restore?
Is there any other way to restore my apps&data from my backup file (.ab) using other commands ?
The content of my backup file seems correct though.
Thanks!
Click to expand...
Click to collapse
Sounds like the adb backup didnt copy the /storage/sdcard0/android/ folder on the sdcard perhaps? Maybe try using adb pull to copy the scdard seperately in addition to doing the adb backup to be safe. You could push the sdcard data back manually if the restore doesnt. See below:
scandiun said:
On some devices you can't specify destiny forlder in order to use adb push or pull, you have to use current folder:
Code:
cd C:\folderyoumade
adb pull /storage/sdcard0/folderyouwant/
It's better to backup the sdcard this way than using adb backup because it also backups the Android folder inside the sdcard.
!
Click to expand...
Click to collapse

it doesnt work

Why?
klvnhng said:
You forgot the frontslash at the end of 0. Try that
Click to expand...
Click to collapse
I font understand why is the front slash required?
I also forgot the front slash and was facing the same problem. Now its working after adding the front slash.
So, why is the front slash required and what does it mean ?

can I backup the sd card even if it is external using this method (apps are moved there too)?
edit: ok, I got the android folder from sd card, the message was:
/storage/sdcard1/Android/: 147 files pulled. 0 files skipped.,
but how am I supposed to see them?
I contacted AppMgr III, maybe they can tell me

Related

How to use ADB Sync?

Hi!
I have a folder on my SD Card that I want to sync with a folder on my computer.
I currently use a .bat file with ADB Pull, but this is not ideal as ADB Pull does not check if the file is already present in the destination folder, and therefore copies and overwrites the files in question.
Please advise
Zappza said:
Hi!
I have a folder on my SD Card that I want to sync with a folder on my computer.
I currently use a .bat file with ADB Pull, but this is not ideal as ADB Pull does not check if the file is already present in the destination folder, and therefore copies and overwrites the files in question.
Please advise
Click to expand...
Click to collapse
I think its:
adb sync [sdcard/folder]
This should do no harm with an unrooted phone (untested).

How to Mass Install Apps with ADB?

So, I want to do a flash and have backed up all the APPs into a folder. So, is there anyway to install all the apps onto the phone that is in inside the backed up folder using ADB after I reinstalled? I know this should be possible since there is a way to do a mass pull using ADB.
shaolinx said:
So, I want to do a flash and have backed up all the APPs into a folder. So, is there anyway to install all the apps onto the phone that is in inside the backed up folder using ADB after I reinstalled? I know this should be possible since there is a way to do a mass pull using ADB.
Click to expand...
Click to collapse
Could write a batch file/shell script to iterate through a folder and adb install the contents of it.
shaolinx said:
So, I want to do a flash and have backed up all the APPs into a folder. So, is there anyway to install all the apps onto the phone that is in inside the backed up folder using ADB after I reinstalled? I know this should be possible since there is a way to do a mass pull using ADB.
Click to expand...
Click to collapse
Sure there is:
If you have app2sd:
adb push folder of apps /system/sd/app
If not:
adb push folder of apps /data/app
Assuming adb is in your path, open a command prompt at the folder containing your APKs and issue:
Code:
for %f in (*.apk) do adb install "%f"
Thanks all, both of your way works.
Thanks
Awesome thank you for the help. Have been trying to figure this out for a while.
AdamPI's answer will only work if you use a virus instead of an operating system. The correct answer is this;
for FILE in *; do /path/to/adb install "$FILE"; done

Transfer system files to external SD card?

My motherboard is toast, I bought a broken phone on ebay and switched out the motherboards but it isnt working. Phone works fine but wont recognize sim card or connect to network. Its just a camera/wifi device atm. So anyway..... I can still get the old motherboard to kinda work enough to play with it, the home buttons dont work or the power button and sometimes freezes up. Is there a way I can put the old motherboard in the phone and copy the system files to the external sd card or computer, then wipe the new motherboard and copy the files from the old mb to the new mb? I believe I have tried everything else but if anyone has any suggestions Im all ears
Thanks!
The easiest way would probably be to take the motherboard you're wanting to pull stuff from, hook it up (in the phone), and via USB in ADB do something like this:
adb pull / \backup
That would create a folder at the top level of your C: drive with all the contents of the phone on it. You could then move all of that to the new motherboard.
(That would probably be something like:
adb push \backup /
but I'm not 100% sure on that. You may have to do a more one-by-one procedure.)
when I try to push the backup I get this message....
failed to copy '\backup/acct/uid/0/task' to 'acct/uid/0/task' : Operation not permitted
Sooooo what did I do wrong??
Also I couldnt find where it saved the backup on my computer.
Ok, found the backup folder on my c: drive but what do I do with it now?
Bump cause I still havent figured this out Seems like I dont have the correct permissions in adb.
poprocksncoke said:
when I try to push the backup I get this message....
failed to copy '\backup/acct/uid/0/task' to 'acct/uid/0/task' : Operation not permitted
Sooooo what did I do wrong??
Also I couldnt find where it saved the backup on my computer.
Ok, found the backup folder on my c: drive but what do I do with it now?
Click to expand...
Click to collapse
If you typed in your backup like what you wrote above (\backup/acct/uid/0/task), it's likely that you're running into an error because you flipped your slashes midway through.
The backup folder needs to be in the platform-tools folder of the ADB installation, as that's where ADB pushes from.
Once you have that, reboot into recovery mode. This may not be 100% necessary, but I usually find that pushes work better from there as the file system is (usually) read-write.
Then, try this:
adb push \backup /
(You may have to switch the slash before the word backup so it reads /backup, I'm not 100% sure.)
If that doesn't work, drag an individual folder out of the backup folder to the main platform-tools folder and type:
adb push /acct \
You'll have to repeat that for each folder, but it should work.
If all that fails, you can try to make a CWM flashable zip file. I don't know exactly what the procedure is for doing this, but I would guess that the answer exists somewhere on this site.
jmtheiss said:
If you typed in your backup like what you wrote above (\backup/acct/uid/0/task), it's likely that you're running into an error because you flipped your slashes midway through.
The backup folder needs to be in the platform-tools folder of the ADB installation, as that's where ADB pushes from.
Once you have that, reboot into recovery mode. This may not be 100% necessary, but I usually find that pushes work better from there as the file system is (usually) read-write.
Then, try this:
adb push \backup /
(You may have to switch the slash before the word backup so it reads /backup, I'm not 100% sure.)
If that doesn't work, drag an individual folder out of the backup folder to the main platform-tools folder and type:
adb push /acct \
You'll have to repeat that for each folder, but it should work.
If all that fails, you can try to make a CWM flashable zip file. I don't know exactly what the procedure is for doing this, but I would guess that the answer exists somewhere on this site.
Click to expand...
Click to collapse
Actually what I typed was adb push \backup / then it gave me that error. It stored the backup folder on my c: drive, I will move it to the tools folder and see if that works. Going to go search on how to make a CWM flashable zip file now. Maybe i'll give that a shot too. Thanks for your help.
So If I am getting this correctly, I take the custom ROM I have flashed to my phone and then I can add my system files to to the system folder in the ROM I can then flash the ROM again and it will install all my files?
In theory, yes, that should work. All the CWM update file does is write the files inside of it to the folders that the updater-script file tells it to.
Again, this should work IN THEORY.
poprocksncoke said:
So If I am getting this correctly, I take the custom ROM I have flashed to my phone and then I can add my system files to to the system folder in the ROM I can then flash the ROM again and it will install all my files?
Click to expand...
Click to collapse
Ok, I tried this and put the .zip on my sdcard and ran it from recovery. Got an error that I didnt have enough space. Any suggestions?

[Q]–can't transfer my nanodroid backup

I am trying to transfer my backup to my computer. But it only transfer 16mb instead of over 3giga of files.
Sent from my HTC One using XDA Premium HD app
I bet your computer can't see all files, browse the backup folder and check if all files are shown
Sent from my liquid glowing bomb shell
I can see all the file but it only trensfer like 3 file instead of the 15 files the folder
Sent from my HTC One using XDA Premium HD app
quite weird, what exactly happens when you try to copy?
Sent from my liquid glowing bomb shell
You use TWRP I guess? Latest version has this problem there is a version of 2.5.0.0 with updated touch drivers that will work, look in the TWRP thread
It has nothing to do with the touch drivers. It is a new security feature in 2.6+.
It is related to the permissions being allocated to the backup. It is supposed to be a TWRP 'security feature'... to stop someone from copying your backup from your phone.
If you download the attached zip and extract the command file inside to the folder on your pc containing ADB, if you connect your phone to your pc and double click on the command file, it will change the file permissions and allow you then to copy the backup folder to you pc.
When you run it, you will see two command prompt windows open. One closes immediately and you can close the second one manually. It only takes a second to run.
Easy.
oreitan13 said:
I am trying to transfer my backup to my computer. But it only transfer 16mb instead of over 3giga of files.
Click to expand...
Click to collapse
Hi,
It has happened to me (with my old laptop but I don't really know if it's the cause but since I have my new computer I've never had this problem again), try to reboot your phone and transfer your backup but before don't transfer any other files phone->computer or computer->phone, just your backup after the reboot.
viking37 said:
Hi,
It has happened to me (with my old laptop but I don't really know if it's the cause but since I have my new computer I've never had this problem again), try to reboot your phone and transfer your backup but before don't transfer any other files phone->computer or computer->phone, just your backup after the reboot.
Click to expand...
Click to collapse
See my post above
Whare I can find the folder with ADB
Sent from my HTC One using XDA Premium HD app
proctologist said:
It has nothing to do with the touch drivers. It is a new security feature in 2.6+.
It is related to the permissions being allocated to the backup. It is supposed to be a TWRP 'security feature'... to stop someone from copying your backup from your phone.
If you download the attached zip and extract the command file inside to the folder on your pc containing ADB, if you connect your phone to your pc and double click on the command file, it will change the file permissions and allow you then to copy the backup folder to you pc.
When you run it, you will see two command prompt windows open. One closes immediately and you can close the second one manually. It only takes a second to run.
Easy.
Click to expand...
Click to collapse
Thanks in works
Sent from my HTC One using XDA Premium HD app
oreitan13 said:
Whare I can find the folder with ADB
Sent from my HTC One using XDA Premium HD app
Click to expand...
Click to collapse
This means you don't have ADB, you need to install android sdk to get it
Sent from my liquid glowing bomb shell
proctologist said:
It has nothing to do with the touch drivers. It is a new security feature in 2.6+.
It is related to the permissions being allocated to the backup. It is supposed to be a TWRP 'security feature'... to stop someone from copying your backup from your phone.
If you download the attached zip and extract the command file inside to the folder on your pc containing ADB, if you connect your phone to your pc and double click on the command file, it will change the file permissions and allow you then to copy the backup folder to you pc.
When you run it, you will see two command prompt windows open. One closes immediately and you can close the second one manually. It only takes a second to run.
Easy.
Click to expand...
Click to collapse
Thanks for correcting my wrong. only revered to the touch driver because of maybe updated firmware. But It's not much of a feature when everyone can download the "key"
Manual Process
If you would like to do it manually do the following:
Open a command window in the Platform-Tools folder of the Android SDK and then type the following:
adb shell
su
chmod -R 777 /data/media/0/TWRP (note, if you are using 4.1 you will need to remove "/0")
exit
exit
This changes the permission so you can copy all of the data from the TWRP folder.
ineedone said:
Thanks for correcting my wrong. only revered to the touch driver because of maybe updated firmware. But It's not much of a feature when everyone can download the "key"
Click to expand...
Click to collapse
yeah, this "feature" is a pita and a waste of time

[Q] Cannot find backup files after a CWM backup

Hi
I did three backups using CWM, two to internal SD one to external SD. I wanted to copy the backups to my Mac to make some room but I cannot find them.
I updated CWM to "update cwm6037" rebooted the phone, rebooted the Mac. I cannot see the backup on the Android Files Transfer window on my Mac, I cannot see the files on the phone using a variety of file managers including a Root file manager.
On the other hand if I boot the phone in Recovery mode (CMW) I can see the file in the CMW menu, I can restore it then or delete it.
I have a HTCOne 32gigs phone with the latest (3 days ago) of CM
I really look everywhere , did some search with wild cards. I have enabled "invisible on the Mac.
Any idea why.
Didier AKA Fizou
CWM stores backup outside of sdcard. Something like /data/clockworkmod.. Browse to it using ADB Or file explorer
sent from my mobile device
The folder is /data/media/clockworkmod. If I recall, you can pull it from a computer with ADB by running:
adb pull /mnt/shell/emulated/clockworkmod/ "<destination folder name>"

Categories

Resources