stefankittel
Goto Top

Lexware Backups strukturiert ablegen und Bericht senden

Hallo,

Auf dem Server legt Lexware ein tägliches Backup in einem Verzeichnis ab.
Der Server wird normal gesichert mir Veeam, aber die Lexware-Backups sind einfach und universell zu handhaben.

Lexware kann aber nur Backup Ja oder Nein und an welchem Wochentag.

Deshalb möchte ich sie aber gerne gestaffelt behalten.
Die letzten 14 Tage, die letzten 8 Sonntage und die letzten 24 Monatsersten. Und am liebsten täglich eine Email mit einem kurzen Bericht ob die Dateien da sind und die Größe plausibel.

Bevor ich jetzt selber ein Skript erstell wollte ich fragen ob das schon mal Jemand gemacht hat oder eine (kauf-) Software kennt die das macht.

Stefan

Content-Key: 7066473224

Url: https://administrator.de/contentid/7066473224

Printed on: May 4, 2024 at 10:05 o'clock

Mitglied: 7010350221
7010350221 May 08, 2023 updated at 13:44:57 (UTC)
Goto Top
Hi.
Habe zwar mit Lexware nichts am Hut und kenne deren Ablage nicht, aber hier ein mögliches Powershell-Gerüst, vielleicht spart's dir ja schon etwas Zeit ...
# Backup folder
$backupFolder = 'E:\Backups'  
# logfile
$logfile = 'E:\backup_purge.log'  
# usual Size of each backup
$usualBackupSize = 500MB
# start logging
Start-Transcript -Path $logfile -Append
# get all backups
$backups = Get-ChildItem $backupFolder -File 
# get backup from today
$today = $backups | ?{$_.CreationTime.Date -eq (get-date).Date} | select -First 1

# prepare purge of old backups (keep some backups)
$keep = @()
# last 14 days
$keep += $backups | ?{$_.CreationTime -ge (get-date).Date.AddDays(-14)}
# last 8 Sundays
$keep += $backups | sort CreationTime -Descending | ?{$_.CreationTime.DayOfWeek -eq [System.DayOfWeek]::Sunday} | select -First 8
# last 24 first of month
$keep += $backups | sort CreationTime -Descending | ?{$_.CreationTime.Day -eq 1} | select -First 24
# filter out backups to purge
$purge = $backups | ?{$_.Fullname -notin $keep} 
# delete old backups
if ($purge){
    $purge | remove-item -Force -Verbose
}else{
    write-host "Nothing to purge."  
}

# define body of report
$body = @"  
BACKUP REPORT
===============
$(if ($today.Count -eq 1 -and $today.Length -gt $usualBackupSize){
    "Current Backup plausible."  
}else{
    "WARNING: Current Backup non existent or unusual size!"  
})

$(if($purge){
    "OLD BACKUPS PURGED:"  
    "-------------------"  
    $purge.Fullname -join "`r`n"  
}else{
    "Nothing to purge."  
})
"@  
# send mail 
Send-MailMessage -From "user@domain.de" -to "empfaenger@domain.de" -Subject "Backup-Report" -SmtpServer smtp.domain.de -UseSSL -body $body  
# stop logging
Stop-Transcript
Gruß