diff options
-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." |