aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xandroid-backup42
1 files changed, 22 insertions, 20 deletions
diff --git a/android-backup b/android-backup
index 70c5006..882abc2 100755
--- a/android-backup
+++ b/android-backup
@@ -3,33 +3,35 @@
# Android backup
#
-# Parameters
-basename="`basename $0`"
-name="$1"
-date="`date +%Y%m%d`"
-base="/storage/emulated/0"
-storage="/var/backups/remote/$name.`facter domain`/"
-previous="`sudo ls -1 $storage | tac | head -n 1`"
+# Basic parameters
+BASENAME="`basename $0`"
+NAME="$1"
# Check
-if [ -z "$name" ]; then
- echo "$basename: missing phone name"
+if [ -z "$NAME" ]; then
+ echo "$BASENAME: missing phone name"
exit 1
fi
+# Additional parameters
+DATE="`date +%Y%m%d`"
+BASE="/storage/emulated/0"
+STORAGE="/var/backups/remote/$NAME.`facter domain`/"
+PREVIOUS="`sudo ls -1 $STORAGE | tac | head -n 1`"
+
# Work folder
cd ~/load || exit 1
-mkdir -p $date && cd $date
+mkdir -p $DATE && cd $DATE
# Check
-if [ -d "$storage/$date" ]; then
- echo "backup for $date already exists"
+if [ -d "$STORAGE/$DATE" ]; then
+ echo "backup for $DATE already exists"
exit 1
fi
# If you have a previous backup you might want to use it with hardlinks
-if [ -e "$storage/$previous/files" ]; then
- sudo cp -alf $storage/$previous/files files
+if [ -e "$STORAGE/$PREVIOUS/files" ]; then
+ sudo cp -alf $STORAGE/$PREVIOUS/files files
fi
# Ensure we have a files folder
@@ -43,20 +45,20 @@ adb shell content query --uri content://com.android.contacts/contacts > contacts
adb backup -all
# Files: full copy
-#adb pull $base files/
+#adb pull $BASE files/
# Remove multimedia cache from backup
#rm -rf files/Music
# Files: full basic copy
-#adb shell ls -1 $base | grep -v ^Music | while read file; do
-# adb pull $base/$file files/
+#adb shell ls -1 $BASE | grep -v ^Music | while read file; do
+# adb pull $BASE/$file files/
#done
# Files: incremental basic copy
-for file in `adb shell ls -1 $base | grep -v '^Music'`; do
- adb-sync --delete --reverse $base/$file files/
+for file in `adb shell ls -1 $BASE | grep -v '^Music'`; do
+ adb-sync --delete --reverse $BASE/$file files/
done
# Move backup to storage
-cd .. && sudo mv $date $storage/
+cd .. && sudo mv $DATE $STORAGE/