Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore backup using tar #115

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions backup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,14 @@ fi
clear

if [ ! -v export_method ]; then
cecho "Choose the exporting method."
cecho "Choose the exporting/importing method."
cecho "- Pick 'tar' first, as it is fast and most reliable, but might not work on all devices."
cecho "- If the script crashes, pick 'adb' instead, which works on all devices."
cecho "Press Enter to pick your preferred method."
wait_for_enter

export_methods=( 'tar' 'adb' )
select_option_from_list "Choose the exporting method." export_methods[@] export_method
select_option_from_list "Choose the exporting/importing method." export_methods[@] export_method
fi

clear
Expand Down
9 changes: 9 additions & 0 deletions functions/helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,15 @@ function get_file() {
fi
}

# Usage: send_file <directory> <file> <destination>
function send_file() {
if [ "$export_method" = 'tar' ]; then
(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
else # we're falling back to adb push if the variable is empty/unset
adb push "$1"/"$2" "$3" || cecho "Errors occurred while restoring $2 - this file (or multiple files) might've been ignored." 1>&2
fi
}

# Usage: directory_ok <directory>
# Returns 0 (true) or 1 (false)
function directory_ok() {
Expand Down
4 changes: 1 addition & 3 deletions functions/restore_func.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,9 @@ function restore_func() {
fi
set -e

# TODO: use tar to restore data to internal storage instead of adb push

# Restore internal storage
cecho "Restoring internal storage."
adb push ./backup-tmp/Storage/* /storage/emulated/0
send_file ./backup-tmp/Storage . /storage/emulated/0

# Restore contacts
cecho "Pushing backed up contacts to device."
Expand Down