Files
hyperv-backup-scripts/README.md
2025-12-12 09:54:03 +11:00

99 lines
3.0 KiB
Markdown

# Hyper-V Backup Scripts
Automated backup solution for Hyper-V virtual machines with three-tier backup strategy.
## Overview
This repository contains PowerShell scripts for comprehensive Hyper-V VM backup and management:
- **Daily Snapshots** - Checkpoint-based incremental backups (7pm)
- **Weekly Live Backups** - Live backups without downtime (Friday 8pm)
- **Monthly Full Backups** - Complete VM exports with shutdown (First Sunday 1am)
## Features
- 🔄 Load-balanced checkpoint management
- 💾 7-Zip compression for storage efficiency
- 📦 Three-phase workflow: local processing → compression → NAS transfer
- 🛡️ Critical server protection (business hours awareness)
- 📊 Comprehensive logging and error handling
- 🔧 Automated retention policies
## Scripts
### Daily-SnapshotBackup.ps1
Creates daily VM checkpoints with staggered scheduling across two groups for load balancing.
- **Schedule**: 7pm daily
- **Retention**: 3 checkpoints per VM (6 days coverage)
- **Groups**: VMs divided into two groups with 2-day intervals
### weekly_vmbackup.ps1
Live backup using checkpoints without VM downtime.
- **Schedule**: Friday 8pm
- **Retention**: 2 weekly backups (local and NAS)
- **Compression**: 7-Zip (mx=7)
### monthly_vmbackup.ps1
Full shutdown export for complete VM backup.
- **Schedule**: First Sunday 1am
- **Retention**: 3 monthly backups (local and NAS)
- **Compression**: 7-Zip (mx=9 maximum)
### HyperVCheck.ps1
Quick status check for all VMs and their checkpoints.
### HyperVDiag.ps1
Comprehensive diagnostic tool for performance issues and merge operations.
## Configuration
All scripts use the following paths (configurable):
- **NAS**: `\\nas5362\Backups`
- **Temp**: `F:\TempBackup`
- **Local Backups**: `F:\Backups`
- **7-Zip**: `C:\Program Files\7-Zip\7z.exe`
## Usage
```powershell
# Daily snapshots - All VMs
.\Daily-SnapshotBackup.ps1 -AllVMs -MaxSnapshots 7
# Weekly backup - All VMs except critical servers
.\weekly_vmbackup.ps1 -AllVMs -ExcludeVMs @("PS01", "DC01") -MaxBackups 2
# Monthly backup - All VMs except critical servers
.\monthly_vmbackup.ps1 -AllVMs -ExcludeVMs @("PS01", "DC01") -MaxBackups 3
# Check VM status
.\HyperVCheck.ps1
# Run diagnostics
.\HyperVDiag.ps1 -Detailed -ExportReport
```
## Task Scheduler Integration
All scripts are designed to run via Windows Task Scheduler:
- Daily: 7pm (snapshots)
- Weekly: Friday 8pm (live backups)
- Monthly: First Sunday 1am (full backups)
## Infrastructure
- **Platform**: Windows Server 2022
- **Hyper-V**: Version 10.0.20348.1
- **Storage**: F: drive for processing, NAS for long-term storage
- **Critical Servers**: PS01, DC01 (weekend-only maintenance)
## Backup Strategy
1. **Local Processing First**: All operations on F: drive
2. **Compression**: 7-Zip with appropriate levels
3. **Network Transfer**: Bulk copy after all VMs complete
4. **Immediate Cleanup**: Temp files removed after each VM
5. **Retention Management**: Automated on both local and NAS storage
## License
Personal use - Hyper-V backup automation