Files
backup_to_external_m.2/old_scripts/plug_and_play_backup.sh
root 56c07dbe49 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
2025-09-30 17:35:22 +02:00

109 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
# Create PLUG-AND-PLAY Clonezilla USB - No commands to remember!
set -e
USB_DRIVE="/dev/sda"
CLONEZILLA_ISO="clonezilla-live-3.1.0-22-amd64.iso"
echo "Creating PLUG-AND-PLAY Disaster Recovery USB"
echo "============================================"
echo "• Boot USB = Automatic backup starts in 10 seconds"
echo "• No commands to remember"
echo "• 15-20 minute backup with maximum speed"
echo
# Use existing ISO
if [[ ! -f "$CLONEZILLA_ISO" ]]; then
echo "ERROR: $CLONEZILLA_ISO not found!"
exit 1
fi
read -p "Continue to create plug-and-play USB? (yes/no): " confirm
if [[ "$confirm" != "yes" ]]; then
exit 1
fi
# Unmount and recreate USB
sudo umount "${USB_DRIVE}"* 2>/dev/null || true
# Single partition for simplicity
sudo parted "$USB_DRIVE" --script mklabel msdos
sudo parted "$USB_DRIVE" --script mkpart primary fat32 1MiB 100%
sudo parted "$USB_DRIVE" --script set 1 boot on
# Format
USB_PART="${USB_DRIVE}1"
sudo mkfs.fat -F32 -n "AUTOBACKUP" "$USB_PART"
# Mount and install
USB_MOUNT="/tmp/autobackup_$$"
ISO_MOUNT="/tmp/clonezilla_iso_$$"
sudo mkdir -p "$USB_MOUNT" "$ISO_MOUNT"
sudo mount "$USB_PART" "$USB_MOUNT"
sudo mount -o loop "$CLONEZILLA_ISO" "$ISO_MOUNT"
echo "Installing Clonezilla..."
sudo cp -R "$ISO_MOUNT"/* "$USB_MOUNT/"
echo "Installing GRUB..."
sudo grub-install --target=i386-pc --boot-directory="$USB_MOUNT/boot" "$USB_DRIVE"
# Create PLUG-AND-PLAY menu
sudo tee "$USB_MOUNT/boot/grub/grub.cfg" > /dev/null << 'EOF'
set timeout=10
set default=0
menuentry "🚀 AUTO BACKUP (10 second countdown)" {
linux /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset ocs_live_run="ocs-sr -q2 -j2 -z0 -i 0 -sfsck -scs -rescue -batch -p reboot savedisk AUTO_$(date +%Y%m%d_%H%M%S) /dev/nvme0n1" ocs_live_extra_param="" keyboard-layouts= ocs_live_batch="yes" locales= vga=normal nosplash
initrd /live/initrd.img
}
menuentry "🔧 Manual Clonezilla (for restore)" {
linux /live/vmlinuz boot=live union=overlay username=user config components quiet noswap edd=on nomodeset ocs_live_run="ocs-live-general" ocs_live_extra_param="" keyboard-layouts= ocs_live_batch="no" locales= vga=normal nosplash
initrd /live/initrd.img
}
EOF
# Create instructions
sudo tee "$USB_MOUNT/PLUG_AND_PLAY_INSTRUCTIONS.txt" > /dev/null << 'EOF'
PLUG AND PLAY DISASTER RECOVERY USB
===================================
🚀 BACKUP INSTRUCTIONS:
1. Boot from this USB
2. Wait 10 seconds (auto-backup starts)
3. Wait 15-20 minutes
4. System reboots automatically
🔧 RESTORE INSTRUCTIONS:
1. Boot from this USB
2. Select "Manual Clonezilla"
3. Choose "device-image" -> "restoredisk"
4. Find your backup image
5. Select target drive
6. Confirm and wait
NO COMMANDS TO REMEMBER!
Just boot and wait 10 seconds.
Backup will be saved to this USB drive.
Created: $(date)
EOF
sudo mkdir -p "$USB_MOUNT/home/partimag"
# Cleanup
sudo umount "$ISO_MOUNT" "$USB_MOUNT"
sudo rmdir "$USB_MOUNT" "$ISO_MOUNT"
echo
echo "✅ PLUG-AND-PLAY USB CREATED!"
echo "✅ Boot USB = 10 second countdown then auto-backup"
echo "✅ No commands to remember in disaster recovery"
echo "✅ Maximum speed backup (15-20 minutes)"
echo "✅ Instructions stored on USB drive"
echo
echo "DISASTER RECOVERY: Just boot from USB and wait!"