Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Androidのイメージバックアップ (パスやファイル名は端末によって変わるため、適宜変更してください)
# 1. root権限で実行するためsuに
su
# 2. 各イメージがあるパスへ移動する (MediaTekなどでは /dev/block/by-name/ の場合もあります)
cd /dev/block/bootdevice/by-name/
# 3. バックアップ保存用ディレクトリを作成
mkdir /sdcard/backup_img
# 4. cacheとuserdata以外すべてを/sdcardへバックアップする
for file in *; do
if [[ "${file}" = cache* || "${file}" = userdata* ]]; then continue ; else dd if=/dev/block/bootdevice/by-name/"${file}" of=/sdcard/backup_img/"${file}".img ; fi
done
# 5. MD5 のリストをチェック用に作成
echo "" > /sdcard/backup_img/md5.txt
for file in *; do
if [[ "${file}" = cache* || "${file}" = userdata* ]]; then continue ; else
echo "${file}" >> /sdcard/backup_img/md5.txt
md5sum /dev/block/bootdevice/by-name/"${file}" >> /sdcard/backup_img/md5.txt
md5sum /sdcard/backup_img/"${file}".img >> /sdcard/backup_img/md5.txt
echo "" >> /sdcard/backup_img/md5.txt
fi
done
# 1. root権限で実行するためsuに
su
# 2. 各イメージがあるパスへ移動する (MediaTekなどでは /dev/block/by-name/ の場合もあります)
cd /dev/block/bootdevice/by-name/
# 3. バックアップ保存用ディレクトリを作成
mkdir /sdcard/backup_img
# 4. /sdcardへバックアップする
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=/dev/block/bootdevice/by-name/"${file}" of=/sdcard/backup_img/"${file}".img ; else continue ; fi
done
# 5. MD5 のリストをチェック用に作成
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
echo "${file}" >> /sdcard/backup_img/md5.txt
md5sum /dev/block/bootdevice/by-name/"${file}" >> /sdcard/backup_img/md5.txt
md5sum /sdcard/backup_img/"${file}".img >> /sdcard/backup_img/md5.txt
echo "" >> /sdcard/backup_img/md5.txt
else continue ; fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment