summaryrefslogtreecommitdiff
path: root/andbackup.sh
AgeCommit message (Collapse)Author
2018-07-07Rewrite app enumeration functionAaron Ball
Previously this relied on screenscraping and parsing output from the pm tool, which changes between android versions. To maintain better compatibility, we now list installed apps by looking into the /data/app path. Note that this includes shell code to parse out a substring that isn't strictly POSIX compliant. It however does work on three different models of phones, so is *probably* compatible. This might need to be reverted if not though.
2018-06-10Handle no action specifiedAaron Ball
Previously, bash would handle shifting the empty ${@} when no command was specified, but sh should break with error "shift: nothing to shift". Now we handle if no command is specified, by printing an error (action required...) and returning code 1 before executing the shift.
2018-06-09Merge remote-tracking branch 'origin/grammar-spelling-bug-update'Aaron Ball
2018-06-09Moved help command check above root checkAaron Ball
Previously, we checked for root (uid == 0) first, which meant non-root users couldn't print the help text. This moves the check for argument 1 == help out of the normal command check list and above the root check, and adds an early return to prevent further execution when the helptext is requested..
2018-05-19Fix grammar and spelling mistakes.Luke Pahler
2017-10-26Refactored part of the restore processAaron Ball
Previously, we installed the apk, extracted the data tarball to the internal storage, copied the data directory contents to the /data partition, then cleaned up the temp data directory. This increased io and made the restore time much slower. Now we decompress the data backup in memory, and stream its contents straight to the application install destination (/data/data/...). This is orders of magnitude faster and reduces storage io extending the life of the phone storage.
2017-10-25Fixed bug in non-existent apksAaron Ball
Prevoiusly, we didn't check if the apk destination backup directory existed before trying to copy it in. That means that new applications will fail backup of the installer apk. Now we create the parent directory first. Also, now we check if the apk is available on the system itself. In some cases such as with system apps, the installer apk is not in an expected location. Backing up installers for system apks is pointless anyways because /system is mounted as readonly most of the time, so re-installation at a later date couldn't happen without some workarounds.
2017-10-24Fixed bug in tar commandAaron Ball
On more robust posix shells, eval of command options stored in variables appears to be automatic. On standard Android system sh though, this is not the case. Added an eval before the tar command and options so the command will execute correctly.
2017-10-24Fixed parsing of manifest application argumentsAaron Ball
Previously, each application line was broken up into multiple arguments if IFS was found anywhere. This caused application backup arguments to be disassociated with their corresponding applications. Now we parse the file line by line and for each line, the application is read as input field 1 and all arguments are fields 2 and forwads. With this new functionality, it will be *much* easier to add additional backup flags (eg: nocompress, nocleanup, etc). Updated the preserveCache functionality to use the new functionality.
2017-10-20Rewrote the package setup and compression processpackaging-process-refactorAaron Ball
Previously, the packaging process created a working directory in which modifications could be made before the final tarball creation. This was problematic because most of the time, the backup destination is on a vfat filesystem, which doesn't support symlinks. Any packages that used symlinks in their data directory would through "Function not implemented" errors during the initial copy of this directory. There were also space concerns with this approach. This updates the package process to construct a tar command. The constructon of this command is where package modifications can be made (eg: --exclude). The usage of tar directly on the source files removes the need to copy files around. This uses much less storage as well as performs much faster as it is now almost entirely done in memory.
2017-10-14backup_app:Add recovery mode supportAaron Ball
Previously, this function was dependent on a running android system to get application metadata (eg: data path, code path, etc). Now we assume the defaults in global variables (can update them at a later date to be more intelligent should android change the standard...again). Now, the backup process uses POSIX shell compliant code to execute the backup process, without using android system resources. This enables the backup process to run while the system is in recover (eg: TWRP). NOTE: This is currently dependent on TWRP being the recovery of choice, as it checks for the presence of /sbin/twrp to determine if the system is currently in recovery. Support for other recoveries (are there any others?) can be added at a later date.
2017-09-28Fixed bug that caused backup of the entire filesystemAaron Ball
I couldn't reproduce this, but it seems that either when the application is installed but hasn't been launched, the data variable is empty, causing the script to backup /* (leads to a very big backup for one app). Now we check to see if data does not exist or is empty and fail if either is true. Also fixed a return code for application not installed. Was returning 1 (error). Now we return 2 (enoent).
2017-05-18Fixed grep switchesAaron Ball
Stock grep on android does not support long switches (like --only-matching vs -o, or --quiet vs -q, etc). This replaces all long grep arguments with their short equivelants.
2017-04-18Putting "backups" back to Aaron'sLuke Pahler
2017-04-03Ability to restore from a list that has flags.Luke Pahler
Plus more precise logging and added a new global variable.
2017-03-18Starting to implement preservation of cache on a per app basis.Luke Pahler
2017-03-04Updated copyright to 2017Aaron Ball
Also a minor text fix in the usage function notes.
2017-03-04Initial commit of usage functionAaron Ball
Wrote more helpful helptext for this. Now we print each command, what it does, and each command's additional options. Also added a help command.
2017-03-04Implemented basic list package supportAaron Ball
The currently lists all packages, system and user, sorted alphabetically. Still needs more work to add customizable filtering (eg: only user apps or only system).
2017-03-04Conversion to posix compliant shellAaron Ball
Most stock android systems don't have bash installed, which was originally required by this script to work. This limited the scope of this script as not only was root required, but some variant of bash was as well. This now is (mostly) posix compliant and thus should work on most modern and older shells and all Android systems that have sh or bash. To bring it more into compliance... * All functions were converted from 'function name { }' syntax to 'name() {}' syntax * All bash-specific double bracket if statements (if [[ condition ]]; then...) were replaced with the POSIX complaint single bracket/test syntax (if [ condition ]; then...). * All double equals (==) statements were replaced with single equals (=) * Per good practice, most 'echo' statements were replaced with 'printf' statements. Not pertinent to the posix compliance refactor, logging functions were added to standardize output. Log statements have standardized spacing as well as timestamps. Also added set -u to warn of unset variable usage.
2016-10-07Converted backup compression from bzip2 to gzipAaron Ball
Bzip2 isn't available on all android devices, as it is usually installed with busybox or toybox. Gzip however is available in vanilla android.
2016-10-07Restore SELinux restore labelsAaron Ball
Restoring the data does not restore the selinux contexts defined in /file_contexts (oops). This caused restored applications to force close when opened, with an error indicating the database could not be opened. Add restorecon call to restore selinux contexts after restoring the data.
2016-10-07Fixed 'already-installed' check on nougatAaron Ball
Nougat's dumpsys command returns an error message to stdout when a package is checked that is not installed. Marshmallow returns nothing. This changes the 'already-installed' check to look for positive confirmation with 'userId' rather than a negative confirmation of line count of 0.
2016-10-07Added post-restore cleanup and small message fixesAaron Ball
Was extracting data to be restored, but left the extracted version there, taking much space sometimes. This cleans up the data directory after the restore has completed. Also updated a few messages to make them more unified.
2016-10-07Initial commitAaron Ball
This currently performs single backups and restores, lists of backups adn restores (stdin), and lists of backups and restores provided by an inventory file. This version has also been tested on system apps as well as user apps. If an installer apk is available, that is backed up and is reinstalled upon restore. If not, only the data is backed up (and subsequently restored). Note that this requires root.

Generated by cgit