Does it make sense to make a backup of the whole /data folder? - General Questions and Answers

I know that /data/media/0 (= /sdcard) contains user accessible data and /data/data app data, but I don't know what all the rest is for.
Not using the popular Titanium Backup (Pro), and with adb backup deprecated, I am not sure what useful approaches are to make proper backups either using an app, adb or a root shell (being on a custom ROM with microG instead of Google Play Services, I'm not using any Google services and thus can not make use of Google's cloud backup functionality).
If simply going for a full backup of the /data folder, which folders are safe to exclude or is /data/data followed by a backup of /sdcard enough?
Any suggestions are highly appreciated.

With adb root not working ("adbd cannot run as root in production builds"), a simply adb pull /data is not an option, and @Chainfire 's adb Insecure, that was mentioned somewhere, seems to be dead since 2014.
Any other way to pull /data without making a copy to internal storage (not an option if not enough storage available)?
P.S. I have just tried the following, but strangely the exclude option didn't work as it still tried to backup the content of /data/media/0 as well:
Code:
/sdcard/Download # tar cvjf data.tar.bz2 --exclude="/data/media/0" /data

Folder /data/media is Android's user-space where all the Pictures, Videos, Musics, Documents, Movies are stored. The trailing number is user's id.
In order to not backup partitions / folders to phone's internal storage memory, but to computer's HDD, you can use
Code:
adb exec-out
command.

jwoegerbauer said:
Folder /data/media is Android's user-space where all the Pictures, Videos, Musics, Documents, Movies are stored. The trailing number is user's id.
Click to expand...
Click to collapse
I know, and backing up that folder isn't an issue, but the rest is.

Master One said:
I know, and backing up that folder isn't an issue, but the rest is.
Click to expand...
Click to collapse
AFAIK TAR operates on mountpoints: /data/media/<USER-ID> isn't a mountpoint, it's by default mounted as /storage/emulated/<USER-ID>, but I may err, as always.

jwoegerbauer said:
AFAIK TAR operates on mountpoints: /data/media/<USER-ID> isn't a mountpoint, it's by default mounted as /storage/emulated/<USER-ID>, but I may err, as always.
Click to expand...
Click to collapse
tar works with folders, not mount points (same as with zip or any other compression/archive software).

Does it make sense to make a backup of the whole /data folder?
It depends on what you want to backup.
App specific data?

monica lewinsky said:
It depends on what you want to backup.
App specific data?
Click to expand...
Click to collapse
That really just depends on what's worth backing up in /data, that's why I'm asking.
Without having to think about it, a simply backup of the whole /data folder (file based, not the /data partition by running a backup in recovery) would be it, but as shown, that's not an easy task.

As I can see you still don't know difference between partition and mountpoint:
Partition is a formatted - and populated with data - section of device's storage memory. A partition can't get accessed unless it's mounted - what typically is done when Android boots up
Mountpoint is the link to a mounted partition ( such as /system, /data & /cache ).
In your case partition named /data is mounted as similarily named /data . Hence you can access its content ( folders & files ) if not denied by OS.
Remember I already told you this.

@jwoegerbauer, I already know all of that and this is obviously a misunderstanding (likely because I'm not using the correct expressions).
tar does not care if working on mount points, folders or files, so it does not matter if trying to use it on /data/media/<USER-ID>, /storage/emulated/<USER-ID> or /sdcard, which all leads to the same content.
And yes, I want to back up the content of the /data mount point and not the partition itself.

you can use titanium backup to backup apps data instead of the whole data partition

ineedroot69 said:
you can use titanium backup to backup apps data instead of the whole data partition
Click to expand...
Click to collapse
Master One said:
Not using the popular Titanium Backup (Pro)
Click to expand...
Click to collapse
And no intention to (seems abandoned, no further update since November 2019).
I'm looking for a 2-way approach, one for the command line, the other by app. For the latter I'm having an eye on Migrate and OAndBackupX.

Master One said:
With adb root not working ("adbd cannot run as root in production builds"), a simply adb pull /data is not an option, and @Chainfire 's adb Insecure, that was mentioned somewhere, seems to be dead since 2014.
Click to expand...
Click to collapse
Hi, did you make any progress? I'd be interested in the solution
Why not try adb insecure? A working tool doesn't need updates, that may be the reason for lack of development activity.
Also, did you try https://github.com/spion/adbfs-rootless ?

L.E.V. said:
Hi, did you make any progress? I'd be interested in the solution
Why not try adb insecure? A working tool doesn't need updates, that may be the reason for lack of development activity.
Also, did you try https://github.com/spion/adbfs-rootless ?
Click to expand...
Click to collapse
No, didn't follow this any further. Currently just relying on backups of the data partition from recovery, /sdcard content by just copying over and using OAndBackupX (though I haven't been in a situation to actually try a restore).

Related

[Q] How did my sdcard get "wiped" when I installed the newest AOKP ROM?

OK, so I'm using wiped in quotes because according to my available free space, it appears my data is still there somewhere. It's just that it's really not and I don't understand why (or where it may be hiding). I've done this many times and never had this problem, so I don't think I did anything wrong, but here are the steps I took: I made a TWRP backup. I wiped my cache, then my Dalvik cache, and then did a factory reset. I installed the new AOKP ROM (aokp_d2vzw_jb-mr1_build-3), installed Gapps, and installed the flashable zip for Titanium Backup. I then booted into Android with no problem, went through the setup process, and rebooted into TWRP. At that point, I was going to install the flashable update.zip I created from Titanium Backup, but I couldn't find it or any of my normal files or folders. I booted back into Android and checked again with a file explorer and sure enough – it's only showing the basic folders you start with and none of my content is there. Like I said, it appears my data is still there somewhere according to my available free space, but I haven't been able to find it anywhere. When I was in TWRP, I hit the button to restore and it showed me my two Nandroid backups, so I feel like the files have to be hiding somewhere.
I'm not really sure what caused it, but I know the files were still there after the wiping and the factory reset, or else I wouldn't have had the zip files to then flash. Therefore, I feel like it had to be during the AOKP or the Gapps install where my sdcard got erased (I forgot to mention my Titanium Backup somehow never got installed). Oh, and just to be clear, I'm talking about the internal (emulated) sdcard, so I can't simply pull it out and put it in my PC to search the contents.
Does anyone have any idea how this happened or where my files are? I'm tempted to do a restore to see if get everything back so I can then make more backups and store them somewhere else.
On your internal SD, do you have a /0 folder? methinks all your stuff's in there....
It's an artifact of flashing 4.2.1 and it's "multiple user accounts" feature
letinsh said:
On your internal SD, do you have a /0 folder? methinks all your stuff's in there....
It's an artifact of flashing 4.2.1 and it's "multiple user accounts" feature
Click to expand...
Click to collapse
No, I don't have a /0 folder on my sdcard. I did find a /0 folder somewhere in my root, but it only mirrored what's currently on the sdcard.
I found it! It's not on my card, but in the root, under data/media. There is a /0 folder in there as well and it links to the sdcard folder. To be safe, I'm going to first copy everything to my real external sdcard before trying to put it back.
/data/media is the real path for your internal sd card. All the other paths (/mnt/sdcard0, /sdcard, /storage/sdcard0, etc) are just pointers that look at the /data/media location. If you were looking in any of those other locations, the 0 folder should have been seen...
Either way, I'm glad you found your data!
letinsh said:
/data/media is the real path for your internal sd card. All the other paths (/mnt/sdcard0, /sdcard, /storage/sdcard0, etc) are just pointers that look at the /data/media location. If you were looking in any of those other locations, the 0 folder should have been seen...
Either way, I'm glad you found your data!
Click to expand...
Click to collapse
Well, that makes sense, but I assure you it isn't showing. The only thing that's showing is the contents of the /0 folder which is inside the data/media folder.
In other words, it appears the system created a /0 folder in my internal sdcard and decided that new folder would now be my internal sdcard. So if I'm trying to browse the internal sdcard, I have no way of going up a level and getting to my old content; the system considers that part of the root. Luckily, I can use FX File Explorer to get in there and access the files.
JerseyMike4 said:
Well, that makes sense, but I assure you it isn't showing. The only thing that's showing is the contents of the /0 folder which is inside the data/media folder.
In other words, it appears the system created a /0 folder in my internal sdcard and decided that new folder would now be my internal sdcard. So if I'm trying to browse the internal sdcard, I have no way of going up a level and getting to my old content; the system considers that part of the root. Luckily, I can use FX File Explorer to get in there and access the files.
Click to expand...
Click to collapse
It's like that because of Android profiles you can create now on 4.2, so basically I'd you were to make another profile it'd be /1 and so on.
Sent from my SCH-I535 using xda app-developers app
GoonAssJuan said:
It's like that because of Android profiles you can create now on 4.2, so basically I'd you were to make another profile it'd be /1 and so on.
Sent from my SCH-I535 using xda app-developers app
Click to expand...
Click to collapse
That makes sense. But it would have been nice if the system "moved" my data automatically when I upgraded.

Adventures in Android backup

Hi folks,
I've always been annoyed by the lack of a true simple backup option for Android. A recent device failure reminded me of this situation. The purpose of this post is to share my experience, and a solution that seems to work for me.
Google has a built-in backup capability in Android that backs up your contacts (assuming that you keep your contacts with Google), and it'll keep track of what apps you have installed, and it may even back up app settings if the app developer has chosen to opt into that feature. That's a few "if's" already here. Things that will not get backed up for sure are your photos, movies, and anything on your SD card. Also, various customizations, such as home screen layout and even other Android settings don't seem to be restored. Various carriers seem to have their own cloud backup options, but this seems vaguely redundant with some aspects of the Android-level backup, it's not immediately clear if it backs up *everything*, and it may cost extra money every month to have stuff backed up online. No thanks.
So how do you back up your own Android phone? The requirements before proceeding:
Root Access
A custom recovery ROM, such as CWM
Does anybody else find this somewhat ridiculous?
My first venture into backing up into the phone was to go the CIFS route so that stuff could be easily moved off of the phone. (The LG G2 doesn't have an external card). One of the problems with this was that if I didn't unmount the share before leaving the wifi network, some things could behave differently. Back to the drawing board...
First, in order to get as close to a "bare metal" backup, you'll need to make a nandroid backup. And in order to do this, you'll need a recovery rom. There are supposedly apps that do an online nandroid backup, but I've heard that this technique can be problematic at times. The two popular recovery roms are CWM and TWRP. I attempted to load these roms manually, but I'd get an error: "Loki aboot version does not match device". I didn't feel like digging into this much. Some other options, such as ROM Manager said that my phone wasn't supported. In the end I used FreeGee, which can install CWM or TWRP with a single touch.
One other speed bump that I ran into is that at least with the CWM and TWRP versions installed by FreeGee (6.0.4.7, and 2.6.3.3, respectively at this point), If you encrypt your phone, you cannot make a nandroid backup. Really? You have to choose between extra security or having a backup? Android seems to still have a lot of growing up to do. But I digress...
One notable difference that I ran into between TWRP and CWM is that TWRP puts your nandroid backups out in the open on the SD card, while CWM puts them in a protected area. Either technique has a downside. This means that with TWRP backups, a rogue application might be able to access sensitive bits of your phone. With CWM backups, this means that a non-root-enabled application won't be able to access the backups, even if you want it to. We'll run into this later. The other thing I ran into with my LG phone is that backups are dated 1970. Apparently LG doesn't expose time capability to the environment that CWM/TWRP run in. My workaround here is to use ROM Manager to rename the backup accordingly.
Now we've got a nandroid backup, and the next step is to get the data off of the phone. Rsync backup for Android works quite well. The default sdcard backup field used by this app ended up backing up a single symlink to my NAS, so I ended up changing it to back up /storage/emulated/legacy instead, and that works fine. Now with a single click I can sync my photos and anything else that lives on the SD card. And rsync over ssh is quite efficient as well.
Now, how to get the nandroid backups from CWM to rsync. While they're physically on the SD card storage of the phone, they're logically protected and not visible on /sdcard for security reasons. How to we back them up? We need rsync to have root access. I've tried a couple of options to make this happen, either by playing with the command-line options in the rsync android app, as well as by trying to create a wrapper for the rsync binary. No luck with either route. While not as simple, my fallback technique was to run a script to relax the permissions on the directory where the CWM nandroid backups live. And then once I'm done rsyncing them, I run a different script to restore the permissions.
opencwm
#!/system/bin/sh
mount -o rw,remount /
chmod 755 /mnt/shell
mount -o ro,remount /
echo done!
closecwm
#!/system/bin/sh
mount -o rw,remount /
chmod 700 /mnt/shell
mount -o ro,remount /
echo done!
You can use whichever android script runner app you're comfortable with. The (separate) rsync job that I created for CWM backups works on: /mnt/shell/emulated/clockworkmod.
That's about it. What's a sane backup strategy to use for your phone? Once you've got your phone set up mostly how you like, reboot to CWM and create a backup of the OS. Rsync this as described above. As you normally use your phone, rsync the sdcard periodically. If you want to have backups of your apps and system data as well, use something like TitaniumBackup to back them up to the SD card. Encrypt them if you want them to be protected. Now, every time you rsync the SD card, you'll have backups of that app data as well.
So in the end, you'll have a nandroid backup as your "bare metal" backup. I'd only expect you to create these when you do major OS changes. The usual backup will be the normal sdcard rsync job, which functions as an incremental backup. Run this job as frequently as you like. Now if you ever need to restore your phone, go into CWM and restore the backup. Then go restore the SD card contents, and restore the Titanium Backup. You'll obviously need CWM on the new phone (if it was replaced), and if you've cleared the CWM backup off of the phone itself (e.g. due to space constraints) you'll need to copy it back to the phone (or otherwise make it available, e.g. via USB OTG) before proceeding.
I have the same opinion. My set up is Helium.
https://play.google.com/store/apps/details?id=com.koushikdutta.backup
You don't have to be rooted. You do need a PC to give Helium "temp root access" though. If you are rooted this is not required. Essentially it makes a back up of your apps then you can upload these to most of the cloud storage services.
This is not the full solution for settings and customization of the phone etc nor is it the ideal solution. It gives me all my apps, their settings and game saves that I'd be worried about after a factory reset or losing my phone. Google backs up my photos but Helium offers this service too.
Give it a shot, for a simple back up solution it works for me.
forrestgump2000 said:
One notable difference that I ran into between TWRP and CWM is that TWRP puts your nandroid backups out in the open on the SD card, while CWM puts them in a protected area.
Click to expand...
Click to collapse
I've recently switched to TWRP, and it seems that there is an option to encrypt the nandroid backup. So this makes backup easier, as the script to change permissions on the CWM backup location is no longer necessary.
forrestgump2000 said:
I've recently switched to TWRP, and it seems that there is an option to encrypt the nandroid backup. So this makes backup easier, as the script to change permissions on the CWM backup location is no longer necessary.
Click to expand...
Click to collapse
However, the backup is ridiculously slow when encryption is enabled.

TWRP lost my files

I have a XT1033
I've done a nandroid backup, complete with data.
I use AppLock. It has a Photo Vault feature, where you send your pictures you want to hide. I've put many photos there.
I've installed a custom rom over stock 4.4.4
So I did the Nandroid and then format. After that, installed the new rom.
Then I recovery AppLock with TitaniumBackup
Photos gone.
Then I recover that Nandroid backup, absolutely certain that there's no way my files would be gone with a Nandroid backup.
I open AppLock Photo Vault and.... nothing there.
I go to ES file explorar and try to find the files in the .dom0o7b1ile Applock's folder located in sdcard/0/
The directories are all there, but no pictures.
So please someone give some light on what the hell is going on here?? How could the nandroid miss the .XXXX directory??
thanks!
TWRP's data backup excludes the emulated sdcard. TWRP's "factory reset" also excludes the emulated sdcard. But if you format, it will delete all your data, so you should have copied all important files from "internal storage" (aka emulated sdcard) to your computer before.
_that said:
TWRP's data backup excludes the emulated sdcard. TWRP's "factory reset" also excludes the emulated sdcard. But if you format, it will delete all your data, so you should have copied all important files from "internal storage" (aka emulated sdcard) to your computer before.
Click to expand...
Click to collapse
If I get it right, /0 = emulated sdcard? What's the usage of this emulated sdcard? I don't understand how it doesn't backup that since all user files go there? You do a Nandroid backup to backup everything...
fscussel said:
If I get it right, /0 = emulated sdcard?
Click to expand...
Click to collapse
Yes, /data/media or /data/media/0.
fscussel said:
What's the usage of this emulated sdcard?
Click to expand...
Click to collapse
User-managed storage space with no specific per-app permissions.
fscussel said:
I don't understand how it doesn't backup that since all user files go there?
Click to expand...
Click to collapse
On some devices that's the only backup target (with no physical microSD card and no OTG storage), and it often contains a lot of data that you don't want to back up regularly.
fscussel said:
You do a Nandroid backup to backup everything...
Click to expand...
Click to collapse
...that is not easily copied to the PC by other means (e.g. MTP).
_that said:
Yes, /data/media or /data/media/0.
User-managed storage space with no specific per-app permissions.
On some devices that's the only backup target (with no physical microSD card and no OTG storage), and it often contains a lot of data that you don't want to back up regularly.
...that is not easily copied to the PC by other means (e.g. MTP).
Click to expand...
Click to collapse
Man I don't understand this.
/0, is it a shortcut to some folder? Which folder?
How to explain that the directories in the AppLock folder (which name starts with a DOT I don't know the meaning) are all there, only the jpg files are missing? it creates a folder with coded name ex 8943228 for each picture it hides. All foders, one for each picture, are there, only the jpg files missing inside.
Also, since the /0 folder seems to be a shortcut, symbolic link, what-so-ever, is it possible that the files still exists?
So did you format /data or not?
_that said:
So did you format /data or not?
Click to expand...
Click to collapse
I did only after the full Nandroid backup.
Then maybe your data hiding software recreated the directories based on information in app-private data that was restored with your backup. As I said, the emulated sdcard (shared storage) is not backed up as part of /data since whoever wrote that code assumed that users would back up that data by simply copying it elsewhere.
_that said:
Then maybe your data hiding software recreated the directories based on information in app-private data that was restored with your backup. As I said, the emulated sdcard (shared storage) is not backed up as part of /data since whoever wrote that code assumed that users would back up that data by simply copying it elsewhere.
Click to expand...
Click to collapse
But the strange thing is:
When I recover the backup that directory exists even without booting for the first time after restore... in TWRP file manager I go and the directories are there... but not the files... how can this be possible?
Also, since the emulated sdcard refer to a folder, which is that folder? is it a sym link?
???
fscussel said:
When I recover the backup that directory exists even without booting for the first time after restore... in TWRP file manager I go and the directories are there... but not the files... how can this be possible?
Click to expand...
Click to collapse
Not possible if you really formatted /data.
fscussel said:
Also, since the emulated sdcard refer to a folder, which is that folder? is it a sym link?
Click to expand...
Click to collapse
In Android, /sdcard is emulated by the sdcard daemon as a fuse filesystem using /data/media or /data/media/0 as backing storage. In TWRP it's just a bind mount.
_that said:
Not possible if you really formatted /data.
In Android, /sdcard is emulated by the sdcard daemon as a fuse filesystem using /data/media or /data/media/0 as backing storage. In TWRP it's just a bind mount.
Click to expand...
Click to collapse
But how can the directories exist after twrp recovery and not the files (if I really did format /data because I don't really remember) ?

Full backup of dying phone using TWRP, backup should be accessible without the phone

Hello,
I have a Redmi Note 5 with TWRP and AOSP Extended, the charging circuits of which have died, so the phone cannot be charged or even take power from a charger, otherwise entirely functional. I now have my "last charge", the phone is charged to 100% and turned off, but as soon as the battery reaches 0% it is dead, probably forever, as it is not possible to charge it.
Now, I would like to somehow make a backup of the entire phone, in case there is some data that I might find out I need in the future. Is it possible to create a backup that I will be able to fully access after the phone dies? Is it possible to make such an image of the phone, that I could import it into a virtual machine and run on my computer?
Thank you very much.
Using TWRP file manager you can backup your pictures, video, documents etc. To your SD card,, otg or pc. But you can't backup you /data. Data and internal storage are different. Data doesn't include pictures or videos. It just includes your apps and apps data. To backup this /data you have to use migrate or titanium backup. A /data backup of a perticular device from TWRP, might not boot on another device. So use migrate. You can select the apps you want to backup and you can put that in your SD card or drive. That apps can easily be flashed on other phones. TWRP only backs up /data NOT internal storage
Android emulators run on x86/x86-64 CPU based machines whereas Android OS - all it installed apps included - runs on 32-bit/64-bit ARM-CPU based devices. Hence it doesn't make any sense trying to clone an existing Android device in order to run this clone in an Android emulator. It simply doesn't work.
Tab E said:
Using TWRP file manager you can backup your pictures, video, documents etc. To your SD card,, otg or pc. But you can't backup you /data. Data and internal storage are different. Data doesn't include pictures or videos. It just includes your apps and apps data. To backup this /data you have to use migrate or titanium backup. A /data backup of a perticular device from TWRP, might not boot on another device. So use migrate. You can select the apps you want to backup and you can put that in your SD card or drive. That apps can easily be flashed on other phones. TWRP only backs up /data NOT internal storage
Click to expand...
Click to collapse
You are wrong. The /data partition - also called /userdata - is located on device's internal storage memory. To keep you updated: The /data partition has subfolder /data/media where user's data like pictures, musics, videos, etc.pp are stored.
The /data partition what also holds all apps and their data ( obb excluded ) installed by user in subfolder /data/apps always - using the right tool - can completely get backed up.
Tab E said:
Using TWRP file manager you can backup your pictures, video, documents etc. To your SD card,, otg or pc. But you can't backup you /data. Data and internet storage are different. Data doesn't include pictures or videos. It just includes your apps and apps
Tab E said:
Using TWRP file manager you can backup your pictures, video, documents etc. To your SD card,, otg or pc. But you can't backup you /data. Data and internet storage are different. Data doesn't include pictures or videos. It just includes your apps and apps data. To backup this /data you have to use migrate or titanium backup. A /data backup of a perticular device from TWRP, might not boot on another device. So use migrate. You can select the apps you want to backup and you can put that in your SD card or drive. That apps can easily be flashed on other phones
Click to expand...
Click to collapse
data. To backup this /data you have to use migrate or titanium backup. A /data backupof a perticular from TWRP, might not boot on another device. So use migrate. You can select the apps you want to backup and you can put that in your SD card or drive. That apps can easily be flashed on other phones
Click to expand...
Click to collapse
jwoegerbauer said:
You are wrong. The /data partition - also called /userdata - is located on device's internal storage menory. The /data partition has subfolder /data/media where user's data like pictures, musics, videos, etc.pp are stored. The /data partition what also holds all apps and their data ( obb excluded ) installed by user always - using the right tool - can completely get backed up.
Click to expand...
Click to collapse
Thanks for informing
Thank you everyone for clarifying, I ended up just making a backup of the internal storage manually and then all the other partitions using TWRP backup.

backup /data/media WITHOUT root.

The subject says it all...... Anyone know of any way to do this on a stock android file system?? (7.0 Nougat)
Thanks
Sandman
Partition /data/media contains all of the contents of what you think of as your internal sdcard.
To backup it use ADB Backup method.
Thanks
xXx yYy said:
Partition /data/media contains all of the contents of what you think of as your internal sdcard.
To backup it use ADB Backup method.
Click to expand...
Click to collapse
SO if I copy data/media/0 over too my external SD card it would be the same a creating a .tar file from within TWRP??
A .TAR-file is a compressed archive-file, whereas a simple copy of files / folders always is uncompressed.
Other than compression, either way would have identical backup content; that's what I was asking.

Categories

Resources