backupmanagement
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
backupmanagement [2024/12/25 10:49] – created Darren | backupmanagement [2024/12/30 23:47] (current) – old revision restored (2024/12/25 10:57) Darren | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | # User Guide for VM Backup and Snapshot Retention Script | + | ====== |
- | ## Overview\\ | + | === Overview |
This script automates the process of backing up virtual machines (VMs) and managing snapshot retention. It reads configurations from an external INI file, allowing for customizable settings without modifying the script directly. The script uses PowerShell cmdlets and RoboCopy for backup operations and manages snapshots for virtual machines. | This script automates the process of backing up virtual machines (VMs) and managing snapshot retention. It reads configurations from an external INI file, allowing for customizable settings without modifying the script directly. The script uses PowerShell cmdlets and RoboCopy for backup operations and manages snapshots for virtual machines. | ||
- | ### Features\\ | + | ==== Features |
- | - Automated VM snapshot creation.\\ | + | |
- | - Retention management for old snapshots.\\ | + | |
- | - Configurable backup paths and options.\\ | + | |
- | - Dynamic inclusion of VMs via the INI file.\\ | + | |
- | - Detailed logging of operations.\\ | + | |
- | - Fully customizable through an easy-to-use configuration file. | + | |
- | --- | + | ---- |
- | ## Prerequisites\\ | + | === Prerequisites |
- | 1. **System Requirements: | + | |
- | - Windows Server or Windows 10/11 with Hyper-V installed.\\ | + | |
- | - PowerShell 5.0 or later. | + | |
- | 2. **Required Permissions: | + | - **Required Permissions: |
- | - Administrative privileges to manage VMs and access file paths. | + | |
- | 3. **Dependencies: | + | - **Dependencies: |
- | - `RoboCopy` (built into Windows). | + | * '' |
- | 4. **Configuration File:**\\ | + | - **Configuration File:** |
- | - A properly formatted INI file must be created and configured. | + | |
- | --- | + | ---- |
- | ## Configurable Options\\ | + | === Configurable Options |
- | All configurations are stored in the `options.ini` file. | + | All configurations are stored in the '' |
- | ### Example INI File\\ | + | ==== Example INI File ==== |
- | ```ini\\ | + | < |
- | [Settings]\\ | + | [Settings] |
- | RetentionDays = 7\\ | + | RetentionDays = 7 |
- | LocalPath = C: | + | LocalPath = C: |
- | RemotePath = \\BackupServer\VMs\\ | + | RemotePath = \\BackupServer\VMs |
- | LogPath = C:\VMLogs\\ | + | LogPath = C:\VMLogs |
RoboOpts = /MIR /e /FFT /Z /XA:H /W:5 /compress | RoboOpts = /MIR /e /FFT /Z /XA:H /W:5 /compress | ||
- | [VMs]\\ | + | [VMs] |
- | VM1 = MyVirtualMachine1\\ | + | VM1 = MyVirtualMachine1 |
- | VM2 = MyVirtualMachine2\\ | + | VM2 = MyVirtualMachine2 |
- | VM3 = MyVirtualMachine3\\ | + | VM3 = MyVirtualMachine3 |
- | ``` | + | </ |
- | ### Sections and Parameters\\ | + | ==== Sections and Parameters |
- | 1. **[Settings]**\\ | + | |
- | - **RetentionDays**: | + | - **RetentionDays**: |
- | | + | - **Default: |
- | | + | - **Example: |
- | \\ | + | |
- | - **LocalPath**: | + | |
- | - **Example: | + | |
- | - **RemotePath**: Remote destination | + | |
- | | + | - **Example: |
- | - **LogPath**: Directory where log files will be saved.\\ | + | |
- | | + | - **Example: |
- | - **RoboOpts**: Customizable options for RoboCopy. These should | + | |
- | - **Default: | + | - **Example: |
- | - **Example: | + | |
- | 2. **[VMs]**\\ | + | - **RoboOpts**: Customizable options for RoboCopy. These should be formatted as a single string |
- | - List of VMs to be backed up. Each entry should be in the format `VMx = VMName`, where `x` is a unique identifier and `VMName` is the name of the virtual machine.\\ | + | - **Default: |
- | | + | |
- | | + | |
- | | + | |
- | | + | |
- | VM2 = MyVirtualMachine2\\ | + | |
- | VM3 = MyVirtualMachine3\\ | + | |
- | ``` | + | |
- | --- | + | |
+ | | ||
+ | | ||
+ | <code ini> | ||
+ | [VMs] | ||
+ | VM1 = MyVirtualMachine1 | ||
+ | VM2 = MyVirtualMachine2 | ||
+ | VM3 = MyVirtualMachine3 | ||
+ | </ | ||
- | ## Script Functionality | + | ---- |
- | ### Key Components\\ | + | === Script Functionality === |
- | 1. **Snapshot Management**\\ | + | |
- | - The script creates a snapshot for each VM listed in the INI file.\\ | + | |
- | - Old snapshots are removed based on the retention period defined in the `RetentionDays` parameter. | + | |
- | 2. **Backup Process**\\ | + | ==== Key Components ==== |
- | - The script | + | - **Snapshot Management** |
- | | + | - The script |
+ | - Old snapshots are removed based on the retention period defined in the '' | ||
- | 3. **Logging**\\ | + | - **Backup Process** |
- | | + | - The script uses RoboCopy to transfer VM files from the '' |
- | | + | - Configurable options for RoboCopy allow fine-tuning |
- | --- | + | |
+ | | ||
+ | | ||
- | ## How to Use | + | ---- |
- | ### Step 1: Configure the INI File\\ | + | === How to Use === |
- | 1. Open the `options.ini` file in a text editor.\\ | + | |
- | 2. Modify the parameters in the `[Settings]` and `[VMs]` sections as needed.\\ | + | |
- | 3. Save the file. | + | |
- | ### Step 2: Run the Script\\ | + | ==== Step 1: Configure |
- | 1. Open a PowerShell window with administrative privileges.\\ | + | 1. Open the '' |
- | 2. Navigate to the directory containing | + | 2. Modify |
- | 3. Execute | + | 3. Save the file. |
- | | + | |
- | | + | |
- | | + | |
- | 4. The script will automatically read the `options.ini` | + | |
- | ### Step 3: Review Logs\\ | + | ==== Step 2: Run the Script ==== |
- | - Check the log files in the directory specified by `LogPath` for details of the backup process. | + | 1. Open a PowerShell window with administrative privileges. |
+ | 2. Navigate to the directory containing the script. | ||
+ | | ||
+ | <code powershell> | ||
+ | .\BackupScript.ps1 | ||
+ | </ | ||
+ | 4. The script will automatically read the '' | ||
- | --- | + | ==== Step 3: Review Logs ==== |
+ | * Check the log files in the directory specified by '' | ||
- | ## Troubleshooting | + | ---- |
- | ### Common Errors and Solutions\\ | + | === Troubleshooting === |
- | 1. **Error:** " | + | |
- | - **Cause:** RoboCopy options are not split correctly.\\ | + | |
- | - **Solution: | + | |
- | 2. **Error:** "Access Denied"\\ | + | ==== Common Errors and Solutions ==== |
- | - **Cause: | + | - **Error:** "Invalid Parameter #3" |
- | - **Solution: | + | - **Cause: |
+ | - **Solution: | ||
- | 3. **Error:** "VM not found"\\ | + | - **Error:** "Access Denied" |
- | - **Cause:** VM name in the INI file does not match an existing VM.\\ | + | - **Cause: |
- | - **Solution: | + | - **Solution: |
- | --- | + | |
+ | | ||
+ | | ||
- | ## Advanced Usage | + | ---- |
- | ### Customizing RoboCopy Options\\ | + | === Advanced Usage === |
- | - The `RoboOpts` parameter allows you to customize the behavior of RoboCopy.\\ | + | |
- | - Example Options: | + | |
- | - `/MIR`: Mirrors the directory structure.\\ | + | |
- | - `/Z`: Enables restartable mode for interrupted transfers.\\ | + | |
- | - `/XA:H`: Excludes hidden files.\\ | + | |
- | - `/R:N`: Specifies the number of retry attempts. | + | |
- | ### Adding or Removing VMs\\ | + | ==== Customizing RoboCopy Options ==== |
- | - To add a VM:\\ | + | - The '' |
- | 1. Add a new entry in the `[VMs]` section | + | - Example |
- | | + | - ''/ |
- | 2. Save the INI file.\\ | + | - ''/ |
- | - To remove a VM:\\ | + | - ''/ |
- | 1. Delete the corresponding entry in the `[VMs]` section.\\ | + | - ''/ |
- | 2. Save the INI file. | + | |
- | --- | + | ==== Adding or Removing VMs ==== |
+ | | ||
+ | 1. Add a new entry in the '' | ||
+ | - Example: '' | ||
+ | 2. Save the INI file. | ||
- | ## Maintenance and Updates\\ | + | |
- | - **Log Management:** Periodically clean up old logs in the `LogPath` directory to save space.\\ | + | 1. Delete the corresponding entry in the '' |
- | - **INI File Updates:** Review and update | + | 2. Save the INI file. |
- | - **Script Updates:** Check for script updates to ensure compatibility with the latest systems and features. | + | |
- | --- | + | ---- |
- | ## Contact and Support\\ | + | === Maintenance and Updates === |
+ | - **Log Management: | ||
+ | - **INI File Updates:** Review and update the INI file as necessary to reflect changes in the VM environment. | ||
+ | - **Script Updates:** Check for script updates to ensure compatibility with the latest systems and features. | ||
+ | |||
+ | ---- | ||
+ | |||
+ | === Contact and Support | ||
For questions or issues, please contact the script author or system administrator. | For questions or issues, please contact the script author or system administrator. | ||
/var/www/wiki.darrenwindle.co.uk/public_html/data/attic/backupmanagement.1735123753.txt.gz · Last modified: 2024/12/25 10:49 by Darren