aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2017-08-29 08:52:35 -0300
committerSilvio Rhatto <rhatto@riseup.net>2017-08-29 08:52:35 -0300
commite58cfe72b4af8cfd7f8af14512c9b8a9fe012bcd (patch)
tree51cd1dad678a0ba6e8c1f7dc7d99572406c5b4f9
parent085671d4b0a91f750e03d6417b92cc50fbb71759 (diff)
downloadscripts-e58cfe72b4af8cfd7f8af14512c9b8a9fe012bcd.tar.gz
scripts-e58cfe72b4af8cfd7f8af14512c9b8a9fe012bcd.tar.bz2
Adds android-backup
-rwxr-xr-xandroid-backup54
1 files changed, 54 insertions, 0 deletions
diff --git a/android-backup b/android-backup
new file mode 100755
index 0000000..873a389
--- /dev/null
+++ b/android-backup
@@ -0,0 +1,54 @@
+#!/bin/bash
+#
+# Android backup
+#
+
+# Pasta de trabalho
+cd ~/load
+
+# Parâmetros
+date="`date +%Y%m%d`"
+base="/storage/emulated/0"
+storage="/var/backups/remote/celular.`facter domain`/"
+previous="`sudo ls -1 $storage | tac | head -n 1`"
+
+# Check
+if [ -d "$storage/$date" ]; then
+ echo "backup for $date already exists"
+ exit 1
+fi
+
+mkdir -p $date && cd $date
+
+# Se você tiver um backup antigo e quiser aproveitá-lo com hardlinks:
+sudo cp -alf $storage/$previous/files files
+
+# Garante a existência da pasta de arquivos
+mkdir -p files
+
+# Contatos
+# Exportar também para .vcf direto do aplicativo de contatos
+adb-export.sh -e content://com.android.contacts/contacts
+adb shell content query --uri content://com.android.contacts/contacts > contacts.rows
+
+# Configurações
+adb backup -all
+
+# Arquivos: cópia completa
+#adb pull $base files/
+
+# Remover cache multimídia do backup
+#rm -rf files/Music
+
+# Arquivos: cópia completa básica
+#adb shell ls -1 $base | grep -v ^Music | while read file; do
+# adb pull $base/$file files/
+#done
+
+# Arquivos: cópia incremental básica
+adb shell ls -1 $base | grep -v ^Music | while read file; do
+ adb-sync --delete --reverse $base/$file files/
+done
+
+# Move backup to storage
+cd .. && sudo mv $date $storage/