File tree Expand file tree Collapse file tree 3 files changed +12
-5
lines changed
Expand file tree Collapse file tree 3 files changed +12
-5
lines changed Original file line number Diff line number Diff line change 8383clear
8484
8585if [ ! -v export_method ]; then
86- cecho " Choose the exporting method."
86+ cecho " Choose the exporting/importing method."
8787 cecho " - Pick 'tar' first, as it is fast and most reliable, but might not work on all devices."
8888 cecho " - If the script crashes, pick 'adb' instead, which works on all devices."
8989 cecho " Press Enter to pick your preferred method."
9090 wait_for_enter
9191
9292 export_methods=( ' tar' ' adb' )
93- select_option_from_list " Choose the exporting method." export_methods[@] export_method
93+ select_option_from_list " Choose the exporting/importing method." export_methods[@] export_method
9494fi
9595
9696clear
Original file line number Diff line number Diff line change @@ -208,6 +208,15 @@ function get_file() {
208208 fi
209209}
210210
211+ # Usage: send_file <directory> <file> <destination>
212+ function send_file() {
213+ if [ " $export_method " = ' tar' ]; then
214+ (tar -c -C " $1 " " $2 " 2> /dev/null | pv -p --timer --rate --bytes | adb exec-in tar -C " $3 " -xf -) || cecho " Errors occurred while restoring $2 - this file (or multiple files) might've been ignored." 1>&2
215+ else # we're falling back to adb push if the variable is empty/unset
216+ adb push " $1 " /" $2 " " $3 " || cecho " Errors occurred while restoring $2 - this file (or multiple files) might've been ignored." 1>&2
217+ fi
218+ }
219+
211220# Usage: directory_ok <directory>
212221# Returns 0 (true) or 1 (false)
213222function directory_ok() {
Original file line number Diff line number Diff line change @@ -90,11 +90,9 @@ function restore_func() {
9090 fi
9191 set -e
9292
93- # TODO: use tar to restore data to internal storage instead of adb push
94-
9593 # Restore internal storage
9694 cecho " Restoring internal storage."
97- adb push ./backup-tmp/Storage/ * /storage/emulated/0
95+ send_file ./backup-tmp/Storage . /storage/emulated/0
9896
9997 # Restore contacts
10098 cecho " Pushing backed up contacts to device."
You can’t perform that action at this time.
0 commit comments