Last active
December 1, 2024 21:44
-
-
Save AndroPlus-org/c057a96d0c474f799354b939068337d1 to your computer and use it in GitHub Desktop.
Androidのイメージバックアップ (パスやファイル名は端末によって変わるため、適宜変更してください)
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
# 1. root権限で実行するためsuに | |
su | |
※suコマンドを実行できないGSIの場合は一旦exitでadb shellを抜けて以下を実行 | |
adb root | |
adb shell | |
# 2. 各イメージがあるパスへ移動する (/dev/block/bootdevice/by-name/ の場合もあります) | |
cd /dev/block/by-name/ | |
# 3. バックアップ保存用ディレクトリを作成 | |
mkdir /sdcard/backup_img | |
# 4. cacheとuserdata以外すべてを/sdcard/backup_imgへバックアップする | |
for file in *; do | |
if [[ "${file}" = cache* || "${file}" = userdata* || "${file}" = sd[a-z] ]]; then continue ; else dd if="${file}" of=/sdcard/backup_img/"${file}".img ; fi | |
done | |
# 5. バックアップ元とバックアップ先が完全に一致しているかチェック | |
echo "" > /sdcard/backup_img/md5.txt | |
for file in *; do | |
if [[ "${file}" = cache* || "${file}" = userdata* || "${file}" = sd[a-z] ]]; then continue ; else | |
if cmp -s "${file}" /sdcard/backup_img/"${file}".img; then | |
echo "${file} - OK" >> /sdcard/backup_img/md5.txt | |
else | |
echo "${file} - NG, you have to backup again!" >> /sdcard/backup_img/md5.txt | |
fi | |
fi | |
done |
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
# 1. root権限で実行するためsuに | |
su | |
※suコマンドを実行できないGSIの場合は一旦exitでadb shellを抜けて以下を実行 | |
adb root | |
adb shell | |
# 2. 各イメージがあるパスへ移動する (/dev/block/bootdevice/by-name/ の場合もあります) | |
cd /dev/block/by-name/ | |
# 3. バックアップ保存用ディレクトリを作成 | |
mkdir /sdcard/backup_img | |
# 4. /sdcard/backup_imgへバックアップする | |
for file in *; do | |
if [[ "${file}" = boot* || "${file}" = devcfg* || "${file}" = dtbo* || "${file}" = oem* || "${file}" = recovery* || "${file}" = rpm* || "${file}" = sbl1* || "${file}" = system* || "${file}" = tz* || "${file}" = vbmeta* || "${file}" = modem* || "${file}" = vendor* ]]; then dd if="${file}" of=/sdcard/backup_img/"${file}".img ; else continue ; fi | |
done | |
# 5. バックアップ元とバックアップ先が完全に一致しているかチェック | |
echo "" > /sdcard/backup_img/md5.txt | |
for file in *; do | |
if [[ "${file}" = boot* || "${file}" = devcfg* || "${file}" = dtbo* || "${file}" = oem* || "${file}" = recovery* || "${file}" = rpm* || "${file}" = sbl1* || "${file}" = system* || "${file}" = tz* || "${file}" = vbmeta* || "${file}" = modem* || "${file}" = vendor* ]]; then | |
if cmp -s "${file}" /sdcard/backup_img/"${file}".img; then | |
echo "${file} - OK" >> /sdcard/backup_img/md5.txt | |
else | |
echo "${file} - NG, you have to backup again!" >> /sdcard/backup_img/md5.txt | |
fi | |
else continue ; fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment