use find instead of ls, create backup dir if needed
authorDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 5 Oct 2012 12:57:47 +0000 (14:57 +0200)
committerDobrica Pavlinusic <dpavlin@rot13.org>
Fri, 5 Oct 2012 12:57:47 +0000 (14:57 +0200)
This changes make it work in empty checkout and fix usage of ls -1
which doesn't seem to work with recent Cyanogenmod busybox, see #1

adb-pull-clockworkmod-backup.sh

index ae5008c..d201ff3 100755 (executable)
@@ -2,7 +2,8 @@
 
 sdcard=/sdcard/clockworkmod/
 
-adb shell ls -1 -d $sdcard/backup/* | sed "s!$sdcard/*!!" | tr -d '\r' > /tmp/backup.android
-ls -1 -d backup/* > /tmp/backup.disk
+adb shell find $sdcard/backup/ -mindepth 1 -maxdepth 1 | sed "s!$sdcard/*!!" | tr -d '\r' > /tmp/backup.android
+test -d backup || mkdir backup
+find backup/ -mindepth 1 -maxdepth 1 -type d | sed 's!backup/!!' > /tmp/backup.disk
 diff -uw /tmp/backup.android /tmp/backup.disk | grep -- '^-backup' | sed 's/^-//' | \
 xargs -i sh -xc "mkdir {} && adb pull $sdcard/{} {}"