aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-11-26 13:26:43 -0200
committerSilvio Rhatto <rhatto@riseup.net>2018-11-26 13:26:43 -0200
commit3bc73f18a72f5b8a92d3fe11be75fa377f93edb5 (patch)
tree5cf6c5e0103dd74d646a3e1251b4bcdcdf1baebd
parent0f1fdb1e70fd4cc277a92043b8db0d0afbade663 (diff)
downloadscripts-3bc73f18a72f5b8a92d3fe11be75fa377f93edb5.tar.gz
scripts-3bc73f18a72f5b8a92d3fe11be75fa377f93edb5.tar.bz2
Fix and style android-backup
-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/