What is the right or the best way to backup and restore android app data by terminal emulator in a rooted phone?
su -c cp -r /data/data/the.app.id /sdcard/the/backup/directory can copy the app data, but copying them back will cause some problems. For example, the owner and group of them are not correct, permissions are not right, only root can access them.
I've searched for a while and got some solutions that I don't want. adb backup the.app.id needs a computer.
Some apps cannot access sdcard, so switching to it then copying is not possible. Also, to copy it, iterate through the whole directory and chmod with root takes a lot of time and may not work.
If the question needs more explanations, please tell me by comment. Thanks for reading or answering this.
adb backupdoesn't necessarily need a computer if your device is rooted. Helium Backup uses this approach on-device. But to use it from a terminal, you'd need at least anadbexecutable. AFAIR that's not there anymore by default since Android 6. Also note that apps can opt-out of ADB's backup (devs can setALLOW_BACKUP:FALSEin the Manifest). To work around that, there's an Xposed module (not sure about other approaches to it). – Izzy Jan 03 '18 at 10:44adb connectdoesn't work. adb connects phone to a computer with a usb cable, but how to use adb in the phone to connect into the same phone? I tried Titanium Backup, it doesn't work on my phone. Just found Helium backup and its adb approach, trying it now. – Kirk Jan 03 '18 at 10:58adb backup the.app.idgotadb: unable to connect for backup. Helium works fine! – Kirk Jan 03 '18 at 11:20tarcommand can do it, I've marked this question as "duplicated" to close it according to https://meta.stackexchange.com/questions/10841/how-should-duplicate-questions-be-handled – Kirk Jan 04 '18 at 15:51chown -Rto change the owner – Kirk Jan 06 '18 at 07:22