[Mi 3 General] Silac_8:
This guide is intended for those who own 16G MI3W which, sadly, often doesn't have enough space to make nandroid backup. This tutorial will show you how you can make nandroid backup directly to your PC and restore it later. Entire procedure will not store any single byte to your phone's internal memory.

Great part of this tutorial (and the whole idea) is taken from scandiun's thread, so some credits go to him.

WAS IT NECESSARY?

As we know, this operation (backup and restore) can, sort of, be done using adb backup command. But this command leaves out sms messages, call logs and some other information. So, backup made with adb backup may not be full, and does not reflect phone's current state.

REQUIREMENTS

This tutorial requires you to have:

ClockworkMod custom recovery installed on your phone

BusyBox installed into /system/xbin directory (your device probably already has it there). But you can check it or install it using this application (requires root).

Linux machine or MS Windows. I recommend linux, but if you're using Windows, please install Cygwin with netcat (nc), pv and util-linux (you can select those binaries in Cygwin setup).

Adb installed into some PATH directory. For windows, adb executable could be put into Windows directory (eg. C:\Windows). For linux, you can use command shown here to install adb, which will automatically put adb into your PATH directory.

Let's get down to business!

Whole philosophy lies behind opening some port on your device, over which will /data, /system or /cache partition be transfered from MI3 to PC's hard drive. Data is also being compressed/decompressed on the fly, so backup size is reduced. You can also see transfer speeds and total amount of data transfered.

Process is tested and it works!

BACKUP

To initiate a backup, we first have to run ADB. Connect USB cable to your phone. Then boot your device into recovery and select system 1. After that, go into Storage and mounts and mount /data, /cache and /system.

Finally, open Cygwin/linux shell and type the following:

adb kill-server
sudo adb start-server
adb forward tcp:1234 tcp:1234
adb shell

Then open another Cygwin/linux shell and create and enter directory which will hold MI3 backup. I called my directory mibackup.

mkdir ~/mibackup
cd ~/mibackup

You can see that we are working here with two consoles. First console will always represent phone's memory, and second will always represent our PC.

We will backup total of three partitions: /data, /cache and /system. That is essentially everything you need.

/system holds android system, and /data partition holds internal storage, applications, dalvik-cache and every other data including SMS messages, etc. But be prepared, because backup of this data partition can take up to 12,5GB of PC's hard drive space. It is usually lower because of compression, but just so you know. /system partition can take up to around 600MB, and is also usually lower than that.

/data partition (without internal storage)

Whole backup procedure of /data partition relies on few simple commands. Type this command in your first console, where adb shell is run:

cd /system/xbin
./busybox tar -pcf - /data --exclude='data/media/0' | ./busybox nc -l -p 1234

And then type command below into another shell:

nc localhost 1234 | pv -i 0.5 | gzip -c > data.gz

This will start backup process. As you may have noticed, this will backup our /data partition, but without internal storage (internal SD card).

Internal storage backup

After backup is complete, we can also backup our phone's storage (a.k.a. internal SD card), using following commands.

Type these commands in first console:

cd /system/xbin
./busybox tar -pcf - /data/media/0 | ./busybox nc -l -p 1234

and this command into second console:

nc localhost 1234 | pv -i 0.5 | gzip -c > sdcard.gz

/cache partition

Cache partition does not hold any important data. But I've noticed that when I wiped it, my current theme reset! This partition can be backed up in a matter of seconds, so why wouldn't we give it a try?

Type these commands in first console:

cd /system/xbin
./busybox tar -pcf - /cache | ./busybox nc -l -p 1234

and this command into second console:

nc localhost 1234 | pv -i 0.5 | gzip -c > cache.gz

/system partition

Finally, we can backup our /system partition. But, because BusyBox is located in /system, and we do not want to use this partition while it's in backup/restore phase, we have to copy xbin directory (busybox) to internal SD card.

Type these commands in your first console:

cp -R /system/xbin /data/media/0
cd /data/media/0/xbin
./busybox tar -pcf - /system | ./busybox nc -l -p 1234

and this command into second console:

nc localhost 1234 | pv -i 0.5 | gzip -c > system.gz

After the process is done, type following commands in first console to clean up xbin directory from internal storage, and to close adb.

cd /
rm -rf /data/media/0/xbin
exit
adb kill-server

And you have just created backup of your phone, into chosen directory. Congratulations!

Backup is in this case made of four files: data.gz, sdcard.gz, cache.gz and system.gz.

RESTORE

Before each restore procedure, we should wipe partition we are going to restore. So be careful! It is also important to check if /data, /cache and /system are mounted after each wipe/format.

To prepare things for restoration, open console and type in:

adb kill-server
sudo adb usb
adb forward tcp:1234 tcp:1234
adb shell

Then open another terminal, and go into directory where backups are stored. When I showed you how to create backup, I used mibackup directory. So, let's go into that directory once again, so we can pull our backups from there.

cd ~/mibackup

/data partition (doesn't contain internal storage)

If you are going to restore /data and /sdcard, then go to mounts and storage, and choose the last option - format /data and /data/media.

If you are going to restore only phone's data (and not /sdcard), select wipe data/factory reset from CWM menu. Don't skip this step! After that, make sure that /system and /data partitions are mounted.

To restore data partition then, type this commands into first console:

cd /
/system/xbin/busybox nc -l -p 1234 | tar -px

and this command into second:

gunzip -ck data.gz | pv -i 0.5 | nc localhost 1234

Internal storage

Make sure that /system and /data are mounted.

If you just restored /data partition, you don't have to wipe/format anything. Otherwise, if you just want to restore your internal SD card, you can type following command into first console, to wipe it first:

cd /
rm -rf /data/media/0/*

Type these commands into first console to restore your internal SD card (if you've backed it up):

cd /
/system/xbin/busybox nc -l -p 1234 | tar -px

and this command into second one:

gunzip -ck sdcard.gz | pv -i 0.5 | nc localhost 1234

/cache partition

Make sure that /system and /cache are mounted, and then format /cache from CWM.

/cache partition will be restored just as fast as it was backed up.

Type these commands into first console:

cd /
/system/xbin/busybox nc -l -p 1234 | tar -px

and this command into second console:

gunzip -ck cache.gz | pv -i 0.5 | nc localhost 1234

/system partition

After process is finished, we can restore system partition in a similar fashion we did when we backed it up. Just make sure that /system and /data are mounted, and then format /system from CWM.

Type this commands into first console:

cp -R /system/xbin /data/media/0
cd /
/data/media/0/xbin/busybox nc -l -p 1234 | tar -px

And this command into second one:

gunzip -ck system.gz | pv -i 0.5 | nc localhost 1234

After that, we just have to do some housekeeping jobs:

cd /
rm -rf /data/media/0/xbin
exit
adb kill-server

And last, but not least, if you haven't restored /cache partition, you should format it from CWM recovery.

That's it!