Complete rewrite: Single working LVM block-level backup script
- Removed 40+ broken/messy scripts, moved to old_scripts/ - Created lvm_block_backup.sh - proper block-level LVM snapshot backup - Uses dd for block-level cloning instead of file-level rsync - Successfully tested: 462GB backup in 33 minutes - Creates exact, bootable clone of internal drive to external drive - Proper LVM snapshot management with cleanup - Clear documentation in README_BACKUP.md - Clean, minimal solution that actually works
This commit is contained in:
104
old_scripts/preview_snapshot_migration.sh
Executable file
104
old_scripts/preview_snapshot_migration.sh
Executable file
@@ -0,0 +1,104 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Snapshot Migration Preview Script
|
||||
# Shows what the snapshot-based migration will do
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
# Colors
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
RED='\033[0;31m'
|
||||
NC='\033[0m'
|
||||
|
||||
echo -e "${BLUE}=== Snapshot-Based LVM Migration Preview ===${NC}"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Current System Status:${NC}"
|
||||
echo "✅ Booted from: $(findmnt -n -o SOURCE /)"
|
||||
echo "✅ Volume Group: migration-vg"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Current Logical Volumes:${NC}"
|
||||
sudo lvs migration-vg --units g -o lv_name,lv_size,data_percent 2>/dev/null
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Available Space for Snapshots:${NC}"
|
||||
free_space=$(sudo vgs --noheadings --units m --nosuffix -o vg_free migration-vg | tr -d ' ' | tr ',' '.')
|
||||
if command -v bc >/dev/null 2>&1; then
|
||||
snapshot_size_per_lv=$(echo "$free_space * 0.8 / 4" | bc 2>/dev/null | cut -d. -f1)
|
||||
else
|
||||
snapshot_size_per_lv=$((${free_space%.*} * 80 / 100 / 4))
|
||||
fi
|
||||
echo "Free space: ${free_space}MB"
|
||||
echo "Snapshot size per LV: ${snapshot_size_per_lv}MB"
|
||||
|
||||
if (( snapshot_size_per_lv < 100 )); then
|
||||
echo -e "${RED}⚠️ WARNING: Limited space for snapshots!${NC}"
|
||||
echo "Consider freeing up space or expanding the volume group"
|
||||
else
|
||||
echo -e "${GREEN}✅ Sufficient space for snapshots${NC}"
|
||||
fi
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Target Drive Analysis:${NC}"
|
||||
echo "Internal NVMe (nvme0n1):"
|
||||
lsblk /dev/nvme0n1
|
||||
echo "Size: $(lsblk -b -n -o SIZE /dev/nvme0n1 | awk '{printf "%.1fGB", $1/1024/1024/1024}')"
|
||||
echo
|
||||
|
||||
echo -e "${YELLOW}Snapshot Migration Process:${NC}"
|
||||
echo "1. 📸 Create temporary snapshots of ALL logical volumes:"
|
||||
echo " • root (${snapshot_size_per_lv}MB snapshot)"
|
||||
echo " • home (${snapshot_size_per_lv}MB snapshot)"
|
||||
echo " • boot (${snapshot_size_per_lv}MB snapshot)"
|
||||
echo " • swap (${snapshot_size_per_lv}MB snapshot)"
|
||||
echo
|
||||
echo "2. 🔧 Prepare internal drive:"
|
||||
echo " • Copy partition table from external M.2"
|
||||
echo " • Create LVM physical volume"
|
||||
echo " • Create volume group 'internal-vg'"
|
||||
echo " • Create logical volumes with exact same sizes"
|
||||
echo
|
||||
echo "3. 📋 Transfer data using block-level copy:"
|
||||
echo " • Use dd to copy each snapshot to internal LV"
|
||||
echo " • Process one LV at a time to manage space"
|
||||
echo " • Remove each snapshot after successful copy"
|
||||
echo
|
||||
echo "4. ⚙️ Configure boot:"
|
||||
echo " • Update fstab for new volume group"
|
||||
echo " • Install GRUB on internal drive"
|
||||
echo " • Update initramfs for LVM"
|
||||
echo
|
||||
echo "5. 🛠️ Setup snapshot tools:"
|
||||
echo " • Install lvm-snapshot-manager"
|
||||
echo " • Reserve space for future snapshots"
|
||||
echo
|
||||
|
||||
echo -e "${RED}⚠️ CRITICAL WARNINGS:${NC}"
|
||||
echo "• Internal NVMe will be COMPLETELY WIPED"
|
||||
echo "• This creates an EXACT copy including all current data"
|
||||
echo "• Process takes 1-3 hours depending on data size"
|
||||
echo "• Snapshots use limited available space"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Advantages of Snapshot Method:${NC}"
|
||||
echo "✅ Exact bit-for-bit copy of live system"
|
||||
echo "✅ No filesystem corruption risks"
|
||||
echo "✅ Can capture running system state"
|
||||
echo "✅ Uses LVM native capabilities"
|
||||
echo "✅ Block-level transfer (faster than file copy)"
|
||||
echo
|
||||
|
||||
echo -e "${GREEN}Post-Migration Capabilities:${NC}"
|
||||
echo "• sudo lvm-snapshot-manager create - Create system snapshots"
|
||||
echo "• sudo lvm-snapshot-manager list - Show snapshots"
|
||||
echo "• sudo lvm-snapshot-manager remove - Clean up snapshots"
|
||||
echo "• sudo lvm-snapshot-manager merge - Restore from snapshot"
|
||||
echo
|
||||
|
||||
echo -e "${BLUE}Ready to proceed with snapshot migration?${NC}"
|
||||
echo "Run: sudo ./snapshot_migrate_to_internal.sh"
|
||||
echo
|
||||
echo -e "${YELLOW}Estimated time: 1-3 hours${NC}"
|
||||
Reference in New Issue
Block a user