summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xandbackup.sh20
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"
}

Generated by cgit