diff options
author | Luke Pahler <luke.linked.in+git@gmail.com> | 2017-04-03 18:36:26 -0600 |
---|---|---|
committer | Luke Pahler <luke.linked.in+git@gmail.com> | 2017-04-03 18:36:26 -0600 |
commit | fcdca78a14e43c2d375ce164366373cfa6aaca7e (patch) | |
tree | 4bee0d1822971536161b2a30a29a53a3ab2b7314 | |
parent | 2c68eab918485700a3597226ac6e80f0d1ea7483 (diff) | |
download | andbackup-fcdca78a14e43c2d375ce164366373cfa6aaca7e.tar.gz andbackup-fcdca78a14e43c2d375ce164366373cfa6aaca7e.tar.xz |
Ability to restore from a list that has flags.
Plus more precise logging and added a new global variable.
-rwxr-xr-x | andbackup.sh | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/andbackup.sh b/andbackup.sh index 77624ce..0426b68 100755 --- a/andbackup.sh +++ b/andbackup.sh @@ -21,7 +21,7 @@ set -u #backups=/sdcard/andbackup backups=/storage/ext_sd/bk/andbackup/andbackupBK - +flag_delimiter="-" usage() { # NOTE: The maximum width of this text should be 65 chars. This @@ -89,7 +89,7 @@ backup_app() { #If app has "-" that means options are passed in local preserveCache=false - if [[ 0 = $(echo ${app} | grep --quiet [-]; echo $?) ]]; then + if [[ 0 = $(echo ${app} | grep --quiet [${flag_delimiter}]; echo $?) ]]; then linfo "This app $app has passed in options" if [[ 0 = $(echo ${app} | grep --quiet "preserveCache"; echo $?) ]]; then preserveCache=true @@ -98,9 +98,6 @@ backup_app() { app=`echo ${app} | grep --only-matching ^.*- | sed s/-//g | cat -` fi - #DEBUGGING don't want to actaully install - #return 1 - # Make sure app is installed if [[ $(dumpsys package ${app} | wc -l) -eq 0 ]]; then lerror "Package ${app} appears to not be installed." @@ -131,8 +128,10 @@ backup_app() { # Copy the user data cp -rp ${data}/* ${backups}/${app}/data/ # Delete cache directory if it exists - # This will sometimes significant amounts of space - if [[ -d "${backups}/${app}/data/cache" ]] && ! $preserveCache; then + # This will sometimes free up significant amounts of space + if [[ ! -d "${backups}/${app}/data/cache" ]]; then + linfo "Cache doesn't exist for ${app}" + elif ! $preserveCache; then linfo "Deleting cache for ${app}" rm -rf "${backups}/${app}/data/cache" else @@ -161,6 +160,14 @@ restore_app() { return 1 fi + # When restoring something with flags need to restore app alone + if [[ 0 = $(echo ${app} | grep --quiet [${flag_delimiter}]; echo $?) ]]; then + linfo "This app $app had passed in options" + #Need to get app back to std naming (without params) + app=`echo ${app} | grep --only-matching ^.*- | sed s/-//g | cat -` + linfo "Restoring to std name \"${app}\" while we restore" + fi + # Check that backup exists to be restored if [[ ! -d ${backups}/${app} ]]; then lerror "No backup for ${app} exists." |