Files
backup_to_external_m.2/list_drives.sh
root c86fee78cb fix: Solve space issues in VG→Borg backups
Problem: VG→Borg was creating temp files for all LVs simultaneously,
causing 'no space left' errors when LVs are large.

Solution: Process LVs sequentially instead of simultaneously:
1. Create snapshot for one LV
2. Stream it directly to Borg (no temp files)
3. Remove snapshot immediately
4. Move to next LV

Changes:
- VG→Borg now creates separate archives per LV instead of one big archive
- Each LV gets its own archive: vg_internal-vg_lv_root_20241009_123456
- No temporary files needed - direct streaming
- Space-efficient: only one snapshot exists at a time
- More robust: failure of one LV doesn't affect others

Benefits:
- No more space issues regardless of LV sizes
- Faster cleanup between LVs
- Individual LV recovery possible
- Better error isolation
- Still preserves block-level backup benefits
2025-10-09 00:51:15 +02:00

99 lines
3.9 KiB
Bash
Executable File

#!/bin/bash
# Enhanced script to list available backup sources and targets
# Shows options for all three backup modes
echo "=== Enhanced Simple LVM Backup with Borg Support - Available Options ==="
echo ""
echo "=== SOURCES ==="
echo ""
echo "Logical Volumes (for lv-to-lv and lv-to-raw modes):"
echo "---------------------------------------------------"
if command -v lvs >/dev/null 2>&1; then
echo "Path Size VG Name"
echo "----------------------------------------"
lvs --noheadings -o lv_path,lv_size,vg_name | while read lv_path lv_size vg_name; do
printf "%-24s %-8s %s\n" "$lv_path" "$lv_size" "$vg_name"
done
else
echo "LVM not available"
fi
echo ""
echo "Volume Groups (for vg-to-raw mode):"
echo "-----------------------------------"
if command -v vgs >/dev/null 2>&1; then
echo "VG Name Size PV Count"
echo "----------------------------------"
vgs --noheadings -o vg_name,vg_size,pv_count | while read vg_name vg_size pv_count; do
printf "%-16s %-8s %s PVs\n" "$vg_name" "$vg_size" "$pv_count"
done
else
echo "LVM not available"
fi
echo ""
echo "=== TARGETS ==="
echo ""
echo "Existing Logical Volumes (for lv-to-lv mode):"
echo "---------------------------------------------"
if command -v lvs >/dev/null 2>&1; then
echo "Path Size VG Name"
echo "----------------------------------------"
lvs --noheadings -o lv_path,lv_size,vg_name | while read lv_path lv_size vg_name; do
# Highlight external/backup VGs
if [[ "$vg_name" == *"migration"* ]] || [[ "$vg_name" == *"external"* ]] || [[ "$vg_name" == *"backup"* ]]; then
printf "%-24s %-8s %s (backup VG)\n" "$lv_path" "$lv_size" "$vg_name"
else
printf "%-24s %-8s %s\n" "$lv_path" "$lv_size" "$vg_name"
fi
done
else
echo "LVM not available"
fi
echo ""
echo "Raw Block Devices (for lv-to-raw and vg-to-raw modes):"
echo "------------------------------------------------------"
echo "Device Size Model"
echo "-------------------------"
lsblk -dno NAME,SIZE,MODEL | grep -E '^sd|^nvme' | while read name size model; do
printf "/dev/%-6s %-8s %s\n" "$name" "$size" "$model"
done
echo ""
echo "=== USAGE EXAMPLES ==="
echo ""
echo "1. LV to LV (update existing backup):"
echo " sudo ./enhanced_simple_backup.sh lv-to-lv /dev/internal-vg/root /dev/backup-vg/root"
echo ""
echo "2. LV to Raw Device (fresh backup):"
echo " sudo ./enhanced_simple_backup.sh lv-to-raw /dev/internal-vg/root /dev/sdb"
echo ""
echo "3. Entire VG to Raw Device (complete clone):"
echo " sudo ./enhanced_simple_backup.sh vg-to-raw internal-vg /dev/sdb"
echo ""
echo "4. LV to Borg Repository (block-level backup):"
echo " sudo ./enhanced_simple_backup.sh lv-to-borg /dev/internal-vg/root /path/to/borg/repo --new-repo"
echo " → Stores raw snapshot as 'root.img' in Borg repo"
echo ""
echo "5. Entire VG to Borg Repository (all LVs as block devices):"
echo " sudo ./enhanced_simple_backup.sh vg-to-borg internal-vg /path/to/borg/repo --encryption repokey"
echo " → Creates separate archives for each LV (space-efficient, one LV at a time)"
echo ""
echo "=== GUI VERSION ==="
echo " sudo python3 simple_backup_gui.py"
echo ""
echo "=== IMPORTANT NOTES ==="
echo "- Always run as root (sudo)"
echo "- lv-to-lv: Updates existing backup LV"
echo "- lv-to-raw: Creates fresh backup, overwrites target device"
echo "- vg-to-raw: Clones entire VG including LVM metadata"
echo "- lv-to-borg/vg-to-borg: Creates block-level backups in Borg (preserves exact LV state)"
echo "- LV→Borg: Single archive with one .img file, VG→Borg: Separate archives per LV"
echo "- VG→Borg processes one LV at a time to avoid space issues"
echo "- Borg backups are deduplicated, compressed, and encrypted"
echo "- Borg backups require: sudo apt install borgbackup"
echo "- Make sure target devices are unmounted before backup"
echo ""