From ce8f83c48d200106ff61ad530c863b15c16949d9 Mon Sep 17 00:00:00 2001 From: bigbiff Date: Sat, 12 Dec 2015 18:30:21 -0500 Subject: ADB: Add adb backup for TWRP. Functionality for client side to backup tar and image streams over adbd to the client under backup.ab. Using adb backup on the client side you can backup the partitions TWRP knows about. On the client side you can do the following: adb backup -f --twrp where options are --compress: compress data system: backup system cache: backup cache data: backup data boot: backup boot etc for each partition. You can string multiple options, i.e. adb backup -f --twrp --compress cache system data adb backup in TWRP will take any option corresponding to TWRP fstab partitions, e.g. efs boot as well. If you do not specify the filename with the -f option, adb will backup your data to a filename backup.ab on the client. You can then rename the file and encrypt it with desktop tools. If you don't want to use command line arguments: adb backup --twrp will bring up the gui and allow you to choose partitions from the backup page. To restore the backup use the following convention: adb restore Structures are used to store metadata in binary inside of the file itself. If the metadata structure is modified, update the adb version so that it will invalidate older backups and not cause issues on restore. When restoring, we currently do not support picking specific partitions. It's all or nothing. Change-Id: Idb92c37fc9801dc8d89ed2a4570e9d12e76facf8 --- twrp-functions.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'twrp-functions.hpp') diff --git a/twrp-functions.hpp b/twrp-functions.hpp index 3f9b2ff5a..550c946f0 100644 --- a/twrp-functions.hpp +++ b/twrp-functions.hpp @@ -34,6 +34,13 @@ typedef enum rb_download, } RebootCommand; +enum Archive_Type { + UNCOMPRESSED = 0, + COMPRESSED, + ENCRYPTED, + COMPRESSED_ENCRYPTED +}; + // Partition class class TWFunc { @@ -46,7 +53,7 @@ public: static int Exec_Cmd(const string& cmd); //execute a command static int Wait_For_Child(pid_t pid, int *status, string Child_Name); // Waits for pid to exit and checks exit status static bool Path_Exists(string Path); // Returns true if the path exists - static int Get_File_Type(string fn); // Determines file type, 0 for unknown, 1 for gzip, 2 for OAES encrypted + static Archive_Type Get_File_Type(string fn); // Determines file type, 0 for unknown, 1 for gzip, 2 for OAES encrypted static int Try_Decrypting_File(string fn, string password); // -1 for some error, 0 for failed to decrypt, 1 for decrypted, 3 for decrypted and found gzip format static unsigned long Get_File_Size(const string& Path); // Returns the size of a file static std::string Remove_Trailing_Slashes(const std::string& path, bool leaveLast = false); // Normalizes the path, e.g /data//media/ -> /data/media -- cgit v1.2.3