I'm not a developer or something even near to that. I'm a newbie and will be, seems so. All information provided here is copied and compiled from different internet sources. This information is according to best of my knowledge and comprehension and is just for curious souls like me who want to understand things in quite simple words.
I have tested this on different devices. I'll not be responsible for any harm to you or your device. It works perfectly for me. You may try it on your own risk.
Encrypted memory may cause problem in backing up and restoring data. So better decrypt it before proceeding. Or the Recovery should support decryption of /data partition.
WHY YOU NEED TO BACKUP YOUR DATA
- For security, in case if device is lost. Read here more about the risks.
- If you are going to change your device.
- If your device is running out of memory space.
- If your device is slowing down or giving random errors and you want a clean start i.e. by factory data reset.
- If you are upgrading your Factory Firmware or ROM (OS).
- If you are a curious soul like me and interested in experimenting with device.
WHAT TO BACKUP
Backup is a broad term used in many contexts.
On an android device, backing up personal data like pictures, music, videos, documents, e-books etc. means backing up Internal Memory (/data/media/) and SD card (if you use one). If you have disabled internal memory (D.I.M), your SD Card would be working as Internal Memory.
Personal data might be created by apps (like Camera, Facebook, WhatsApp etc) or imported from internet or other devices by yourself.
APPS & APPS DATA
If you are upgrading your ROM permanently, you might be interested in backing up your apps and their data as well. So that you don't lose important data and don't have to install apps again. System apps are stored in different folders under /system/ while user apps under /data/.
Apps typically store their data in /data/data/ but it's not a rule. Many apps save / backup their data on Internal Memory and/or SD Card as well. That's why you see folders named 'Android', 'data' etc. on Internal Memory and SD Card. Also, there are numerous folders named after app names. These folders may contain Personal Data as well, created by that certain app.
Contacts and messages are also stored in their default apps' data folder i.e. in /data/data/ and are not usually backed up manually.
OPERATING SYSTEM & APPS & APPS DATA
If you are going to install new ROM temporarily, you may want a complete backup so that you don't have to go through the hassle of installing apps and setting up / personalizing your device again. It usually includes /system, /boot and /data partitions.
OS consists of SYSTEM and BOOT. While user apps & apps data is stored in DATA.
From a developer's perspective, one may want to backup the whole device partitions, in case if something goes wrong during experimenting.
Read here more about android partitions.
WHERE TO BACKUP
INTERNAL MEMORY (/sdcard) (/storage/sdcard0) (/data/media/0)
This memory can be used to save data if you are not going to wipe / clean it. A Factory Data Reset usually doesn't wipe this but it can. It depends on the device. Similarly, Recoveries usually don't wipe internal memory but you can manually do so. However, formatting /data would certainly erase internal memory. Formatting might be a part of flashable zip if you are going to install new ROM. Flashing Factory Firmware using flasher will also erase internal memory.
EXTERNAL SD CARD (/external_sd) (/storage/sdcard1)
This is a more safer place to save / backup data because it is not wiped unless done manually or accidentally.
PERSONAL COMPUTER (USB Flash drive or Internal / External Hard Disk)
This is the safest place to keep data with abundant space and the least chances of losing / corrupting data.
ONLINE / CLOUD STORAGE
Some apps, including Google offer backing up your data online and auto-synchronizes it. You should certainly avail this option particularly for sensitive and light weight data like contacts, messages, documents, saved passwords, bookmarks, financial transactions etc. WhatsApp also has a good online backup option. You can use apps like Drive, SMS Backup & Restore, FolderSync, KeepSafe etc. to better utilize this option. But technically, this is a limited option.
HOW TO BACKUP
FILE EXPLORER APPS
You can use a file explorer like ES Explorer or Solid Explorer to manually copy files from, say, Internal Memory to SD Card to back it up.
Some default apps have built-in feature to backup data and settings locally and online e.g. GO-SMS, Tasker etc. You can check apps for this feature.
Also, special backup apps like Titanium Backup can backup almost all of your user and system apps and their data. It can also backup contacts, messages, device settings etc. It can create a flashable zip of backed up data to flash through recovery. However, backups from one ROM may not fully work with other ROM's.
Backing up data when ROM is running isn't safe. When files are being used by OS, they might not be written / read sometimes. So, a custom recovery is the best option to backup/restore data. Custom recoveries (TWRP/CWM) can backup / restore partitions SYSTEM, BOOT and DATA (excluding internal memory) for sure. Some new recoveries offer backing up more (or all) partitions on device. You can choose where to save backup files i.e. Internal Memory or SD Card. Then you can transfer these files to PC as well.
You can also use recovery's File Explorer to copy Internal Memory to SD Card. However, it's a slower process if you have a large number of files to backup.
You can use PC in multiple ways to backup/restore data within device or from/to PC.
- First of all, you will often come across different software advertised on net claiming to fully backup your device when connected to PC. They work but are not much useful / reliable according to my experience. Give them a try, if you want to.
- Secondly, you can use USB cable to directly connect your device (as MTP in ROM or recovery) to PC or use apps like Wi-Fi File Transfer to wirelessly connect (in ROM) and then explore Internal Memory and SD Card. FTP or SFTP (SSH) server may also be setup on Android to remotely access it from PC if both are on same network.
- Thirdly, you can mount SD Card as flash drive (UMS in ROM) or switch off your device, remove SD Card and then insert directly into PC through card reader to manually copy files. This method is faster, to copy large data. However, mounting as UMS in running ROM isn't recommended, particularly if you are using D.I.M. It will crash apps.
In Android 5+ UMS may not be available in USB settings as it has been deprecated in favor of MTP to avoid problems. However, to copy large data from internal SD card is really problematic without direct USB connection. Or what if we need to recover accidentally deleted data from internal memory? We can directly attach internal memory (as in UMS) to PC by a little hacking.
- Fourthly and ultimately, like a boss , you can use life saving ADB feature of android to backup/restore your data as well as recovering your device from difficult situations and doing a lot of stuff. It's the best and fastest method to backup Internal Memory to SD Card and then restore (COPY WHOLE FOLDER (within device)). Or you can COPY WHOLE FOLDER (From/To PC) or COPY WHOLE PARTITION IMAGE (within device) or BACKUP / RESTORE APPS & DATA (From/To PC) in seconds.
Read here more about android partitions.