1
0
Fork 0
knowledge-base/KB/Android/backup-smartphone

39 lines
1.2 KiB
Bash

#!/usr/bin/env sh
# Requires working adb and abe (for extracting .ab files)
# DIR TO BACKUP
BACKUP_DIR="$HOME";
# POSSIBLE BACKUP ADB PARAMETERS
# -apk/-noapk: do/don't back up .apk files (default -noapk)
# -obb/-noobb: do/don't back up .obb files (default -noobb)
# -shared|-noshared: do/don't back up shared storage (default -noshared)
# -all: back up all installed applications
# -system|-nosystem: include system apps in -all (default -system)
ADB_PARAMS="-apk -obb -noshared -all -system"
UNPACK=false # true or false, unpack .ab to .tar with abe
# DO NOT TOUCH BELOW
date=$(date +"%Y-%m-%d_%H-%M-%S");
BACKUP_FILE="$BACKUP_DIR/$date-backup.ab";
BACKUP_FILE_TAR="$BACKUP_DIR/$date-backup.tar";
echo "Extracting to $BACKUP_FILE";
echo "Taring to $BACKUP_FILE_TAR";
echo "Using adb parameters $ADB_PARAMS";
echo "";
echo "Backup might take a while and adb shows no progress bar";
echo "";
echo "!!!!!!";
echo "Storage is not included. Backup manually.";
echo "Some folders might be included if you provide the -shared parameter to adb, but not all."
echo "!!!!!!";
adb backup $ADB_PARAMS -f "$BACKUP_FILE";
if [ "$UNPACK" = true ]; then
abe unpack "$BACKUP_FILE" "$BACKUP_FILE_TAR";
fi
echo "Finished";