diff options
author | Aaron Ball <nullspoon@oper.io> | 2017-10-24 22:23:06 -0600 |
---|---|---|
committer | Aaron Ball <nullspoon@oper.io> | 2017-10-24 22:23:06 -0600 |
commit | db93b197c77ae9557166633db6f42b168675a2b8 (patch) | |
tree | 6e467d4e722162f4d77db26a2c95195878e81490 | |
parent | 1908ff2864e1cc8068dfab51eefc53f96f0cdbe3 (diff) | |
parent | 9a95d9999343026480b6bf934ac31954a64f93de (diff) | |
download | andbackup-db93b197c77ae9557166633db6f42b168675a2b8.tar.gz andbackup-db93b197c77ae9557166633db6f42b168675a2b8.tar.xz |
Merge branch 'packaging-process-refactor'
-rwxr-xr-x | andbackup.sh | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/andbackup.sh b/andbackup.sh index 7f5c239..72b8aac 100755 --- a/andbackup.sh +++ b/andbackup.sh @@ -85,7 +85,10 @@ lfatal() { backup_app() { local app="${1}" - if [ -z "${app}" ]; then + local tar # Tar command for packaging the backup + + # Make sure app is specified + if [[ -z ${app} ]]; then lerror "Application name required." return 1 fi @@ -115,8 +118,6 @@ backup_app() { # Create backup destination if not exist [ ! -d "${backups}" ] && mkdir -p "${backups}" - # Delete data stage directory if it exists so we can start new - [ -d "${backups}/${app}/data" ] && rm -rf "${backups}/${app}/data" # Backup the apk file if it exists if [ ! -z "${apk}" ]; then @@ -150,24 +151,21 @@ backup_app() { linfo "Skipping application force stop while booted to recovery mode." fi - # Copy the user data - cp -rp "${data}" "${backups}/${app}/data" + tar="tar -C ${data} -c " # Delete cache directory if it exists # This will sometimes free up significant amounts of space - if [ ! -d "${backups}/${app}/data/cache" ]; then + if [[ ! -d "${data}/cache" ]]; then linfo "Cache doesn't exist for ${app}" elif ! $preserveCache; then - linfo "Deleting cache for ${app}" - rm -rf "${backups}/${app}/data/cache" + linfo "Excluding cache for ${app}" + tar="${tar} --exclude=cache" else linfo "Preserving cache for ${app}" fi # Compress the backup linfo "Compressing userdata for ${app}" - cd "${backups}/${app}/" - tar -c data | gzip -c > data.tar.gz - rm -rf data + ${tar} . | gzip -c > "${backups}/${app}/data.tar.gz" } |