Last active
March 1, 2021 18:09
-
-
Save p3x-robot/8d973222fc701e2e878604b89444f2ed to your computer and use it in GitHub Desktop.
🖴 clonezilla restore files from image
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
#!/usr/bin/env bash | |
# http://blog.christosoft.de/2012/05/mount-clonezilla-image-to-restore-single-file-browse/ | |
# ./extract-clonzilla /media/patrikx3/SEAGATE-450GB/restore/image.img '/media/patrikx3/SEAGATE-450GB/backup/2017-05-21-17-img/sda1.ext4-ptcl-img.gz.*' | |
# $1 = destination - full path eg /media/clonzilla/image.img | |
# $2 = source = '/media/backup/date/sda1.ext4-ptcl-img.gz.*' (import ' in the file, since * is needed!) | |
echo DESTINATION: $1 | |
echo SOURCE: $2 | |
# $1 = /media/patrikx3/SEAGATE-450GB/backup/2017-05-21-17-img/sda1.ext4-ptcl-img.gz.* | |
# $2 = /media/clonzilla/image.img | |
# sudo apt-get install partclone | |
DESTPATH=`dirname $1` | |
DESTNAME=`basename $1` | |
mkdir -p $DESTPATH | |
touch $1 | |
cat $2 | gzip -d -c | partclone.restore --restore_raw_file -C -s - -O $1 | |
MOUNTED=/media/restore-$RANDOM | |
mkdir -p $MOUNTED | |
fsck.ext4 -f -n $1 | |
# sudo mount -o loop -t ext3 /dir-to-new-image/partition.img /mnt | |
# -t ext4 | |
mount -o loop $1 $MOUNTED | |
echo MOUNTED: $MOUNTED | |
echo SAVED FILE: $1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment