FORUMS
Remove All Ads from XDA

[GUIDE][Windows] Making backups with adb

859 posts
Thanks Meter: 372
 
By klvnhng, Senior Member on 19th August 2013, 05:02 PM
Post Reply Email Thread
Quote:

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.

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/
Quote:

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).

Quote:

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.

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.
The Following 25 Users Say Thank You to klvnhng For This Useful Post: [ View ] Gift klvnhng Ad-Free
 
 
23rd August 2013, 10:26 PM |#2  
klvnhng's Avatar
OP Senior Member
Flag Toronto
Thanks Meter: 372
 
Donate to Me
More
Reserved
12th December 2013, 04:07 PM |#3  
Senior Member
Thanks Meter: 30
 
More
Quote:
Originally Posted by klvnhng

Reserved

Good method if MTP failes or crashes! Thanks!
28th January 2014, 04:26 PM |#5  
Junior Member
Thanks Meter: 0
 
More
I get remote object '/storage/sdcard0' not a file or directory when I try pull. Help?
29th January 2014, 09:41 PM |#6  
klvnhng's Avatar
OP Senior Member
Flag Toronto
Thanks Meter: 372
 
Donate to Me
More
Quote:
Originally Posted by nphone

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

You forgot the frontslash at the end of 0. Try that
The Following User Says Thank You to klvnhng For This Useful Post: [ View ] Gift klvnhng Ad-Free
27th December 2014, 09:46 AM |#7  
scandiun's Avatar
Senior Member
Thanks Meter: 914
 
More
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.
27th December 2014, 11:54 PM |#8  
yethz's Avatar
Senior Member
Flag Tagbilaran City
Thanks Meter: 545
 
Donate to Me
More
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)
_________________________________________________
The Following User Says Thank You to yethz For This Useful Post: [ View ] Gift yethz Ad-Free
10th February 2015, 02:27 AM |#9  
ccs86's Avatar
Senior Member
Thanks Meter: 63
 
More
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.
21st July 2015, 07:37 AM |#10  
jbfountain's Avatar
Senior Member
Flag Castaic, California
Thanks Meter: 397
 
Donate to Me
More
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.
The Following User Says Thank You to jbfountain For This Useful Post: [ View ] Gift jbfountain Ad-Free
14th September 2015, 05:50 PM |#11  
Member
Thanks Meter: 0
 
More
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.
Post Reply Subscribe to Thread

Tags
adb, backup, nexus 4, sdcard, windows

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread