├── .gitattributes ├── README.md └── DailyBackup.ps1 /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Macrium Backup 2 | Macrium Backup - Powershell 3 | 4 | ### .SYNOPSIS 5 | Macrium Reflect Daily Backup 6 | 7 | ### .DESCRIPTION 8 | Script to run and send notifications for Macrium Reflect 9 | 10 | ### .FUNCTIONALITY 11 | * Frees up space on target drive if necessary 12 | * Runs Macrium Reflect using specified XML config 13 | * Copies Macrium html log file to webserver 14 | * Creates short link to log file 15 | * Emails report with link to log file 16 | 17 | ### .PARAMETER 18 | * -s = ? 19 | * -full = full backup 20 | * -inc = incremental backup 21 | * -diff = differential backup 22 | * [empty] = clone 23 | 24 | ### .NOTES 25 | Run daily from task scheduler with administrator privileges 26 | 27 | ### .EXAMPLE 28 | PS C:\Windows\system32> C:\scripts\Reflect\DailyBackup.ps1 -diff 29 | -------------------------------------------------------------------------------- /DailyBackup.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | 3 | .SYNOPSIS 4 | Macrium Reflect Backup 5 | 6 | .DESCRIPTION 7 | Script to run and send notifications for Macrium Reflect 8 | 9 | .FUNCTIONALITY 10 | * Frees up space on target drive if necessary 11 | * Runs Macrium Reflect using specified XML config 12 | * Copies Macrium html log file to webserver 13 | * Creates short link to log file 14 | * Emails report with link to log file 15 | 16 | .PARAMETER 17 | -s = ? 18 | -full = full backup 19 | -inc = incremental backup 20 | -diff = differential backup 21 | [empty] = clone 22 | 23 | .NOTES 24 | Run daily from task scheduler with administrator privileges 25 | 26 | .EXAMPLE 27 | PS C:\Windows\system32> C:\scripts\Reflect\DailyBackup.ps1 -diff 28 | 29 | #> 30 | 31 | 32 | <### SCRIPT PARAMETERS ###> 33 | Param([switch]$s, [switch]$full, [switch]$inc, [switch]$diff) 34 | 35 | 36 | <### USER VARIABLES ###> 37 | 38 | <# Reflect Variables #> 39 | $strReflectPath = "C:\Program Files\Macrium\Reflect\reflect.exe" 40 | $strXmlFilePath = "C:\Users\User\Documents\Reflect\DailyBackup.xml" 41 | 42 | <# AutoDelete Variables #> 43 | $DoDelete = $True # For testing - set to false to run and report without deleting any old image files 44 | $ImageDir = "D:\Images" # Target folder for backup images 45 | $BackupsToKeep = 3 # How many differential files should be kept 46 | $Safety = 2 # Multiplier of largest file size - used to compare to drive free space to ensure image target drive has enough free space to fit new backup image 47 | 48 | <# Email Variables #> 49 | $EmailFrom = "notify@mydomain.tld" 50 | $EmailTo = "admin@mydomain.tld" 51 | $Subject = "Macrium Nightly Backup" 52 | $SMTPServer = "mydomain.tld" 53 | $SMTPAuthUser = "notify@mydomain.tld" 54 | $SMTPAuthPass = "supersecretpassword" 55 | $SMTPPort = 587 56 | $SSL = $True # If true, will use tls connection to send email 57 | $UseHTML = $True # If true, will format and send email body as html (with color!) 58 | 59 | <# Log Variables #> 60 | $MacriumLogDir = "C:\ProgramData\Macrium\Reflect" # Default location 61 | $WebDir = "X:\xampp\htdocs\mydomain.tld\maclog" # File location of web dir to place log files for online viewing 62 | $WebBaseURL = "https://maclog.mydomain.tld/" # Please leave trailing slash "/" 63 | $YoURLsToken = 'secrettoken' # YoURLs API token 64 | $YoURLsURI = 'https://url.mydomain.tld' # YoURLs Base URL 65 | 66 | 67 | <### FUNCTIONS ###> 68 | 69 | Function Email ($EmailOutput) { 70 | If ($UseHTML){ 71 | If ($EmailOutput -match "\[OK\]") {$EmailOutput = $EmailOutput -Replace "\[OK\]","[OK]"} 72 | If ($EmailOutput -match "\[INFO\]") {$EmailOutput = $EmailOutput -Replace "\[INFO\]","[INFO]"} 73 | If ($EmailOutput -match "\[ERROR\]") {$EmailOutput = $EmailOutput -Replace "\[ERROR\]","[ERROR]"} 74 | If ($EmailOutput -match "^\s$") {$EmailOutput = $EmailOutput -Replace "\s"," "} 75 | Write-Output "