Skip to content

Instantly share code, notes, and snippets.

@Hayao0819
Created June 26, 2022 03:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Hayao0819/53807f4649382e90bc93038c5d18f5e5 to your computer and use it in GitHub Desktop.
Save Hayao0819/53807f4649382e90bc93038c5d18f5e5 to your computer and use it in GitHub Desktop.
Backup your partition on Android
#!/bin/sh
blockdir=/dev/block/bootdevice/by-name
output=/sdcard/Download/PartitionBackup
exclude="userdata,hoge"
if ! [ "$(whoami)" = root ]; then
echo "Run as root" >&2
exit 1
fi
mkdir -p "$output"
for file in "$blockdir/"*; do
if echo "$exclude" | tr "," "\n" | grep -qx "$(basename "$file")"; then
continue
fi
#fileはフルパス
dd if="$file" of="${output}/$(basename "$file")"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment