How to fully back up Android in system partition and data points

Source: Internet
Author: User
Tags symlink

The Andrews system backup is very case-ready to use. The following Python script. It can be used to back up the entire data partition: The files and folders of all data partitions are packaged data.zip. and generate recovery dedicated edify script update-script.sh.

Of course, the backup system partition, assuming a few lines of code, you can back up boot,recovery,uboot and so on partitions. It's just that you write different backup codes based on different partitions:

backup.py

Import sysimport osfrom os.path import joinfrom os import pathimport zipfilefrom zipfile import zipfiledef packdir (dir,z,d Irinfo,emptydirs,linkinfo): dirs = Os.listdir (dir) if not Dirs:emptydirs.append (dir) else:for D i n Dirs:absdir = Join (dir,d) if not Path.islink (Absdir) and (Path.isdir (Absdir) or Path.isfile (ABSDI        R): Break Else:emptydirs.append (dir) for D in dirs:absdir = Join (dir,d) st = Os.lstat (absdir) info = [St.st_uid,st.st_gid,st.st_mode] if Path.islink (absdir): Info.app            End (absdir) Linkdir = Os.readlink (absdir) Linkinfo[linkdir] = info elif path.isdir (absdir):            Dirinfo[absdir] = info Packdir (absdir,z,dirinfo,emptydirs,linkinfo) elif path.isfile (Absdir): Dirinfo[absdir] = info Os.utime (absdir, (1403408099,1403408099)) Z.write (Absdir) el Se:print ' FIle type Unknow%s '% (absdir,) Zi = zipfile (' Data.zip ', ' W ', ZipFile. zip_deflated) Dirinfo = {}emptydirs = []linkinfo = {}packdir ('/data ', zi,dirinfo,emptydirs,linkinfo) f = open (' Update-script.sh ', ' WB '), F.write (' IfElse (is_mounted ("/data"), Unmount ("/data"), 0) \ n ') f.write (' Format ' ("Ext4", " EMMC ","/dev/block/data "," 0 ","/data "), \ n ') F.write (' Mount (" Ext4 "," EMMC ","/dev/block/data ","/data "), \ n ') f.write (' Package_extract_dir ("Data", "/data"), \ n ') Mkdir_cmd = ' Run_program ("/sbin/busybox", "mkdir", "-P", "' mkdir_cmd + = '", "' . Join (emptydirs) Mkdir_cmd + = ' ") \ n ' f.write (mkdir_cmd) for key in Dirinfo.keys (): info = dirinfo[key] info = list (inf o) info.append (key) info = tuple (info) set_perm = ' set_perm (%d,%d,%d, '%s '); \ n '%info f.write (set_perm) for Ke Y in linkinfo:info = Linkinfo[key] Info = tuple (info) symlink = ' symlink ('%s ', '%s '); \ n '% (Key,info[3]) Set_pe    RM = ' Run_program ("/sbin/busybox", "Chown", "-H", "Install:install", "%s"), \ n '% (Info[3],) f.write (symlink)F.write (set_perm) f.write (' Unmount ("/data"); F.close () update_script= ' update-script.sh ' Os.utime (Update_script, (1403408099,1403408099)) Zi.write (update_script ) Zi.close ()

How to perform:

Root is the first, and the execution of the script depends on python-for-android.

Then you will have the wrapper script apk in. Either the ADB shell runs through the command line.

Copyright notice: This article blog original article. Blogs, without consent, may not be reproduced.

How to fully back up Android in system partition and data points

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.