Last active
August 5, 2023 07:44
-
-
Save TheGreatJoules/41a41b884f1a25a8afbe88ed89d00fa1 to your computer and use it in GitHub Desktop.
[Bash/RestoreLinux] Restore system to the latest linux iso #bash
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
#!/bin/bash | |
# restore backup | |
DSK='disk3' | |
# Image name (no ext) | |
IMG='latest' | |
# Check for sensible disk | |
export PTYPE=$(diskutil list /dev/$DSK | awk '/GUID_partition_scheme/ {print $2}; /Apple/ {print $2}; /Windows_NTFS/ {print $2}' ) | |
if [ "$PTYPE" ]; then | |
echo "Disk not a SD Card - Contains "$PTYPE | |
exit | |
elif [ ! /dev/$DSK ]; then | |
echo "/dev/$DSK not found" | |
exit | |
fi | |
echo Ensure SD partitions are unmounted! | |
diskutil unmountDisk /dev/$DSK | |
# Check if image exists | |
if [ -s $IMG.img ]; then | |
echo $IMG.img exists | |
elif [ -s $IMG.img.gz ]; then | |
echo Copying $IMG.img.gz | |
echo Ctl+T to show progress! | |
#time gunzip -k $IMG.img.gz | |
time gunzip -kc $IMG.img.gz | sudo dd conv=sync of=/dev/r$DSK bs=4m | |
exit | |
elif [ -s $IMG.zip ]; then | |
echo Copying $IMG.zip | |
echo Ctl+T to show progress! | |
time unzip -p $IMG.zip | sudo dd conv=sync of=/dev/r$DSK bs=4m | |
exit | |
fi | |
echo please wait - This takes some time | |
echo Ctl+T to show progress! | |
time sudo dd conv=sync if=$IMG.img of=/dev/r$DSK bs=4m | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment