[GUIDE][Windows] Making backups with adb

Search This thread

klvnhng

Senior Member
Dec 1, 2012
858
371
Toronto
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/

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

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.
 
Last edited:

nphone

New member
Jan 12, 2013
2
0
I get remote object '/storage/sdcard0' not a file or directory when I try pull. Help?:crying:
 

scandiun

Senior Member
Jul 12, 2010
1,903
983
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.
 
Last edited:

yethz

Senior Member
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)
_________________________________________________
 
  • Like
Reactions: bestgio

ccs86

Senior Member
Nov 16, 2011
702
65
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.
 

jbfountain

Senior Member
Feb 15, 2015
652
395
68
Castaic, California
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.
 
  • Like
Reactions: klvnhng

DylonSaaied

Member
Dec 5, 2014
39
1
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.
 

NikoBe00

New member
Nov 14, 2015
1
0
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!
 

jason2042

Member
Mar 29, 2011
5
0
Amelia, VA
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!

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:

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

patrickdrd

Senior Member
Mar 24, 2015
759
161
OnePlus Nord CE 5G
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
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 25
    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/

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

    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.
    1
    I get remote object '/storage/sdcard0' not a file or directory when I try pull. Help?:crying:

    You forgot the frontslash at the end of 0. Try that
    1
    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)
    _________________________________________________
    1
    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.