Last active
May 18, 2022 16:30
-
-
Save sandersch/3e8de3c7b1806273264b to your computer and use it in GitHub Desktop.
Back up an lvm partition using Clonezilla
This file contains hidden or 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
# Mount image desintion to /home/partimag as desired | |
# No wizards from here. Use the Clonezilla command line | |
# Abort script on any failures, print out commands for debugging | |
set -e | |
set -x | |
# Partition to clone | |
[ -n "$VG_NAME" ] || VG_NAME="systemvg" | |
[ -n "$LV_NAME" ] || LV_NAME="rootlv" | |
# Determine source/destination paths | |
[ -n "$DEVICE_PATH" ] || DEVICE_PATH="/dev/$VG_NAME/$LV_NAME" | |
[ -n "$FS_TYPE" ] || FS_TYPE=`blkid -o value -s TYPE "$DEVICE_PATH" | tr -d '\r\n'` | |
[ -n "$IMAGE_DIR" ] || IMAGE_DIR="/home/partimag/" | |
[ -n "$ARCHIVE_NAME" ] || ARCHIVE_NAME="${VG_NAME}-${LV_NAME}.pcl.gz" | |
# Activate LVM volume group | |
vgchange -a y "$VG_NAME" | |
# Check volume file system integrity | |
fsck.$FS_TYPE "$DEVICE_PATH" | |
# Clone compressed partition image | |
partclone.$FS_TYPE -c -s "$DEVICE_PATH" | pigz -c > "${IMAGE_DIR}/${ARCHIVE_NAME}" | |
# Generate checksums for partition image | |
cd "$IMAGE_DIR" | |
for hash in sha1 md5; do | |
${hash}sum "$ARCHIVE_NAME" > "${ARCHIVE_NAME}.${hash}" | |
done |
Author
sandersch
commented
Jan 3, 2015
Hi
# Use wizard to enable networking, mount image destination to /home/partimag as desired. wget https://gist.github.com/sandersch/3e8de3c7b1806273264b/raw -O clone_lvm_part.sh chmod +x clone_lvm_part.sh # export VG_NAME, LV_NAME, FS_TYPE if desired ./clone_lvm_part.sh
Thanks for that.
Could you please give a hint how to restore the backuped LVs safely ?
Thanks a lot.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment