PowerShell: Feinkörniges Backup in eine ZIP-Datei

06.01.2024
Dieser Inhalt ist bereits etwas älter.
This content is already a bit old.
Bild

Vor kurzem wollte ich auf einem Windows-Server ein Verzeichnis von einer Anwendung sichern. Die Anwendung besteht aus div. Komponenten, welche alle statische Konfigurationsdateien haben. Teilweise sind das .conf, .txt, und auch vereinzelt .json. Die Dateien liegen quer verstreut in div. Unterordnern. Es ist aber auch nicht auszuschließen, das hier auch exotischere Dateien liegen.

Nun liegen in dem Verzeichnis aber auch ausführbare statische Dateien (.exe, .dll), welche ich nicht sichern möchte, da diese ja wieder relativ einfach nachinstalliert werden können. Spannend sind für mich die Konfigurations-Dateien in beliebiger Form (teilweise wurden dort Anpassungen vorgenommen).

Zusätzlich liegen in 2 Unterverzeichnissen eine Postgres-Datenbank, welche natürlich nicht dateibasiert gesichert werden soll, sondern an einer anderen Stelle bereits gesichert wird.

Nun versuchte ich mich an einem PowerShell-Skript, welches mit folgende Dinge ermöglicht:

  • Ausschluss von beliebigen Dateierweiterungen
  • Ausschluss von Unterordnern anhand ihres Namens
  • Ausschluss von Dateien, welche aktuell in Verwendung sind
  • Anlegen eines Ordners nach Datum/Uhrzeit + Rotation nach n Versionen
  • Kompression der zu sichernden Dateien in einer ZIP-Datei (im Optimalfall ohne temporäres Arbeitsverzeichnis)

An sich müsste dies relativ einfach sein, dachte ich mir. Ich versuchte mit div. Funktionen im PowerShell die Ausschlüsse zu implementieren, doch PowerShell ist hier etwas "picky". Nach einigen Stunden kam dann zum Schluss dieses Skript dabei heraus:

# FancyZIPBackup Script Version 1.0.0.1 by Michael Kirgus
# Copyright (c) 2023 Michael Kirgus
# 
# This program is free software: you can redistribute it and/or modify  
# it under the terms of the GNU General Public License as published by  
# the Free Software Foundation, version 3.
#
# This program is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License 
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

param (
    [string]$TargetDirectory = (Get-Location),
    [string[]]$ExcludedSubfolders = @(),
    [string[]]$ExcludedExtensions = @(),
    [string]$DestinationPath = "",
    [string]$DestinationZIPFile = "Backup.zip",
    [string]$BackupFolderTimestampFormat = "yyyy_MM_dd-HH_mm_ss",
    [int]$MaxBackupFolders = 0  # Number of max. versions
)

$FilesArray = New-Object -TypeName 'System.Collections.ArrayList'

function Confirm-FileInUse {
    Param (
        [parameter(Mandatory = $true)]
        [string]$FilePath
    )
    try {
        $FileHandle = [System.IO.File]::Open($FilePath, 'Open', 'Read') # Open file
        $FileHandle.Close() # Opened so now I'm closing
        $FileHandle.Dispose() # Disposing object
        return $false # File not in use
    }
    catch [System.Management.Automation.MethodException] {
        return $true # Sorry, file in use
    }
}

function ListFilesRecursively($Directory) {
    Get-ChildItem -Path $Directory | ForEach-Object {
        $Item = $_
        
        # Check if the item is a directory
        if ($Item.PSIsContainer) {
            $DirectoryName = $Item.FullName
            $DirectoryFolder = $DirectoryName.Split("\")[-1]

            # Check if the directory is in the excluded subfolders list
            if ($ExcludedSubfolders -notcontains $DirectoryFolder) {
                # Recursively go into the directory
                Write-Host "Entering $DirectoryName ..."
                ListFilesRecursively -Directory $DirectoryName
            }
        }
        else {
            $FileExtension = $Item.Extension

            # Check if the file extension is in the excluded extensions list
            if ($ExcludedExtensions -notcontains $FileExtension) {
                # Check if file is in use
                if (!(Confirm-FileInUse -FilePath $Item.FullName)) {
                    $FilesArray.Add($Item.FullName)
                    Write-Host -ForegroundColor Green "Include: " $Item.FullName
                }else{
                    Write-Host -ForegroundColor Yellow "In use, exclude: " $Item.FullName
                }
            }else{
                Write-Host -ForegroundColor Red "Excluded: " $Item.FullName
            }
        }
    }
}

function CreateBackupFolder($BasePath, $TimestampFormat) {
    $Timestamp = Get-Date -Format $TimestampFormat
    $JoinedBackupFolder = Join-Path -Path $BasePath -ChildPath $Timestamp
    Write-Host "Timestamp folder name is $Timestamp"

    if (!(Test-Path -Path $JoinedBackupFolder -PathType Container)) {
        New-Item -Path $JoinedBackupFolder -ItemType Directory
    }

    return $JoinedBackupFolder
}

# Create a backup folder with a timestamp-based name
$BackupFolder = (CreateBackupFolder -BasePath $DestinationPath -TimestampFormat $BackupFolderTimestampFormat)[0]
Write-Host "Destionation folder set to $DestinationPath"
Write-Host "Backup folder set to $BackupFolder"

# Call the function with the start directory
ListFilesRecursively -Directory $TargetDirectory

# Create a ZIP file and add files in the backup folder
if ($FilesArray.Count -gt 0) {
    $DestinationZIPFileFullPath = Join-Path -Path $BackupFolder -ChildPath $DestinationZIPFile
    
    #create zip file
    Add-Type -AssemblyName System.IO.Compression
    Add-Type -AssemblyName System.IO.Compression.FileSystem
    $ZIPFileObject = [System.IO.Compression.ZipFile]::Open(($DestinationZIPFileFullPath), [System.IO.Compression.ZipArchiveMode]::Create)

    # write entries with relative paths as names
    foreach ($fname in $FilesArray) {
        $rname = $(Resolve-Path -Path $fname -Relative) -replace '\.\\',''
        Write-Output $rname
        $zentry = $ZIPFileObject.CreateEntry($rname)
        $zentryWriter = New-Object -TypeName System.IO.BinaryWriter $zentry.Open()
        $zentryWriter.Write([System.IO.File]::ReadAllBytes($fname))
        $zentryWriter.Flush()
        $zentryWriter.Close()
    }
    # release zip file
    $ZIPFileObject.Dispose()
}

if (Test-Path -Path $DestinationZIPFileFullPath -PathType Leaf) {
    Write-Host "Backup ZIP file created: $DestinationZIPFileFullPath"

    # Remove older backup folders if the number exceeds the specified limit
    if (!$MaxBackupFolders -eq 0) {
        $OldBackupFolders = Get-ChildItem -Path $DestinationPath -Directory | Sort-Object -Property CreationTime

        while ($OldBackupFolders.Count -gt $MaxBackupFolders) {
            $OldestFolder = $OldBackupFolders[0]
            Remove-Item -Path $OldestFolder.FullName -Recurse -Force
            Write-Host "Removed old backup folder: $($OldestFolder.FullName)"
            $OldBackupFolders = Get-ChildItem -Path $DestinationPath -Directory | Sort-Object -Property CreationTime
        }
    }
    exit 0
} else {
    Write-Host "Error creating ZIP File: $DestinationZIPFileFullPath"
    exit 1
}
# SIG # Begin signature block
# MIIm1AYJKoZIhvcNAQcCoIImxTCCJsECAQExCzAJBgUrDgMCGgUAMGkGCisGAQQB
# gjcCAQSgWzBZMDQGCisGAQQBgjcCAR4wJgIDAQAABBAfzDtgWUsITrck0sYpfvNR
# AgEAAgEAAgEAAgEAAgEAMCEwCQYFKw4DAhoFAAQUqTjEDhYhSl/GvXb+25SCGDiu
# CDKggh/mMIIFbzCCBFegAwIBAgIQSPyTtGBVlI02p8mKidaUFjANBgkqhkiG9w0B
# AQwFADB7MQswCQYDVQQGEwJHQjEbMBkGA1UECAwSR3JlYXRlciBNYW5jaGVzdGVy
# MRAwDgYDVQQHDAdTYWxmb3JkMRowGAYDVQQKDBFDb21vZG8gQ0EgTGltaXRlZDEh
# MB8GA1UEAwwYQUFBIENlcnRpZmljYXRlIFNlcnZpY2VzMB4XDTIxMDUyNTAwMDAw
# MFoXDTI4MTIzMTIzNTk1OVowVjELMAkGA1UEBhMCR0IxGDAWBgNVBAoTD1NlY3Rp
# Z28gTGltaXRlZDEtMCsGA1UEAxMkU2VjdGlnbyBQdWJsaWMgQ29kZSBTaWduaW5n
# IFJvb3QgUjQ2MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAjeeUEiIE
# JHQu/xYjApKKtq42haxH1CORKz7cfeIxoFFvrISR41KKteKW3tCHYySJiv/vEpM7
# fbu2ir29BX8nm2tl06UMabG8STma8W1uquSggyfamg0rUOlLW7O4ZDakfko9qXGr
# YbNzszwLDO/bM1flvjQ345cbXf0fEj2CA3bm+z9m0pQxafptszSswXp43JJQ8mTH
# qi0Eq8Nq6uAvp6fcbtfo/9ohq0C/ue4NnsbZnpnvxt4fqQx2sycgoda6/YDnAdLv
# 64IplXCN/7sVz/7RDzaiLk8ykHRGa0c1E3cFM09jLrgt4b9lpwRrGNhx+swI8m2J
# mRCxrds+LOSqGLDGBwF1Z95t6WNj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U3RhbXBpbmcgQ0ECEDlMJeF8
# oG0nqGXiO9kdItQwDQYJYIZIAWUDBAICBQCgeTAYBgkqhkiG9w0BCQMxCwYJKoZI
# hvcNAQcBMBwGCSqGSIb3DQEJBTEPFw0yMzEwMDQxNjMwMjBaMD8GCSqGSIb3DQEJ
# BDEyBDCB/fhi5wVqvItx0BGN9caz+omQHjNWqhBAwvKlbDYpv4zuJnnF6FZu0JTF
# f0NYVZYwDQYJKoZIhvcNAQEBBQAEggIADWexRp0Wov2cZxRJPGeliH3Brbg4p5Y3
# 35FV7giOMIElImAUzNeWfTQr/eYWNI27VIcH2zvuKLS3WVAUzCRSN3v/nI3T7R6F
# IoxxsM6WBfN9tvejGo/bsMkiA+51CmgKSTCWSDolSWHTfWd6G1x+v0p7QU2gFO6L
# YQ9cl4/8T8XmgvoEMTO5ShZqffBa1LXN6zZrshK3t1cOz/H9cRZoYbMu59YRQDss
# 6syKwM9hwVHjVUDHn8cdDKf2aSgU6xxIPd1XYd6xinoYdVIpeAJSveiqXIHs39Qh
# PTHbPct+Y0OZuToXvZAYrjpO/ysE+524J82lABazUlEQvVAZT0hr7ZA3aqscgsTJ
# px6gPpO9T/qeFjrKWXFSbly5rel+0RRZRjvUPnT4bZdxui6aVkajwP7shYMLwOdY
# v+hGdYiRVnFCFR+hIEqGNGcAbnvc05mYoMkYkCVstpFfSXzmFzpGXIVC827vUW0E
# XFB12pqpRjDOoFXq8/ERCwNGtfMgXHPRjPQSssVDLM4iiBf76M53c7SQiPg+ZTqy
# 1c9oL0IqEQEfOIs7qjRa6zFsVZxoJ75Xu8JOiUL+jRxlu4pxMmPNowgkmp9EP3IY
# mEtA+K9AOJ1U4FogCd2RjYCtIK+soD/LfwpvKpk4ktGCJ51qHFESUpkSIFrwRCGU
# zFgb++4hwhI=
# SIG # End signature block

Dieses Skript hat 3 Vorteile:

  • Es können beliebig viele Unterordner beliebig viele Dateitypen ausgeschlossen werden
  • Das Skript packt die dann noch übrigen Dateien in eine ZIP-Datei direkt, ohne über ein lokales Arbeitsverzeichnis gehen zu müssen
  • Die Ordnerpfade werden in der ZIP-Datei beibehalten

 

Feedback, suggestions for improvement, further ideas?

Simply use the contact form or send an email directly to info@kirgus.net.