Skip to content

Instantly share code, notes, and snippets.

@TheGreatJoules
Last active August 5, 2023 07:44
Show Gist options
  • Save TheGreatJoules/d3574a9769bd0689b57feff34eb647b1 to your computer and use it in GitHub Desktop.
Save TheGreatJoules/d3574a9769bd0689b57feff34eb647b1 to your computer and use it in GitHub Desktop.
[Bash/Backup] backup the entire linux system to image
# backup linux image
# DSK='disk4' # manual set disk
OUTDIR=./$1/snapshots/
mkdir -p OUTDIR
# Find disk with Linux partition
## Note: This also works with Raspbian
export DSK=`diskutil list | awk '/Linux/ {print $5}' | cut -c 1-5 | uniq`
if [ $DSK ]; then
echo $DSK
echo $OUTDIR
else
echo "Disk not found"
exit
fi
diskutil unmountDisk /dev/$DSK
echo please wait - This takes some time
echo Ctl+T to show progress!
echo $DSK
time sudo dd if=/dev/r$DSK bs=4m | gzip -9 > $OUTDIR/temp.img.gz
#rename to current date
echo compressing completed - now renaming
mv -n $OUTDIR/temp.img.gz $OUTDIR/latest.img.gz
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment