8
0
Skriptentwickung/test/Backup-XWiki.ps1
2024-01-24 16:42:38 +01:00

37 lines
1.1 KiB
PowerShell

# https://www.xwiki.org/xwiki/bin/view/Documentation/AdminGuide/Authentication/
# Authenticate like: username:password@url and add &basicauth=1 at the end
# Setup Credentials and Encode them
$Username = "DigitalData"
$Password = "35452dd!"
$CredentialsPair = "$($Username):$($Password)"
$EncodedCredentials = [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes($CredentialsPair))
# Create Request Header for Basic Authenticastion
$Headers = @{ Authorization = "Basic $EncodedCredentials" }
# Set the url
$Url = "http://wiki.dd/xwiki11/bin/export/XWiki/XWikiPreferences?editor=globaladmin&section=Export"
$Path = "E:\backup.xar"
Write-Host "Downloading Backup from [$($url)].."
# Make the request
$Response = Invoke-WebRequest -Method Get -Uri $Url -Headers $Headers
Write-Host "Download finished!"
# Write the reponse to disk
Write-Host "Streaming file to [$($Path)].."
try {
[System.IO.File]::WriteAllBytes($Path, $Response.Content)
} catch {
Write-Host "An error occurred:"
Write-Host $_
} finally {
$Stream.Dispose()
}
Write-Host "Done!"