Last active
March 2, 2025 23:18
-
-
Save null-dev/9a3b9963f3531bef66bb2a7c381a6a60 to your computer and use it in GitHub Desktop.
Backup/restore private data of any debuggable app on Android without root (uses Shizuku)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
run-as() { | |
local escaped_args=() | |
for arg in "$@"; do | |
escaped_args+=("'${arg//\'/\'\\\'\'}'") | |
done | |
local IFS=' ' | |
rish -c "/system/bin/run-as ${escaped_args[*]}" | |
} | |
backup-app() { | |
if [[ $# -ne 3 ]]; then | |
echo "Backup an app to a .tar.gz file." >&2 | |
echo "usage: backup-app <package> <user> <file>" >&2 | |
return 1 | |
fi | |
run-as "$1" --user "$2" /system/bin/tar -czvf - . > "$3" || return 1 | |
echo ">>> DONE" | |
} | |
restore-app() { | |
if [[ $# -ne 3 ]]; then | |
echo "Restore an app from a .tar.gz file. Replaces all existing app data." >&2 | |
echo "usage: restore-app <package> <user> <file>" >&2 | |
return 1 | |
fi | |
echo ">>> Deleting existing app data:" | |
run-as "$1" --user "$2" /system/bin/find -mindepth 1 -delete || return 1 | |
echo ">>> Restoring new app data:" | |
run-as "$1" --user "$2" /system/bin/tar -xzvf - < "$3" || return 1 | |
echo ">>> DONE" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment