37 lines
1.6 KiB
PowerShell
37 lines
1.6 KiB
PowerShell
# ============================================================================
|
|
# Rein lesendes Sync-Skript (Windows PowerShell)
|
|
# Holt einen aktuellen Datenbank-Abzug (mysqldump) und das Vereins-Logo
|
|
# vom Strato-Produktivserver nach C:\dev\Karatewiki\backups\
|
|
# ============================================================================
|
|
param(
|
|
[switch]$IncludeSampleVideos
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
$SshKey = "$env:USERPROFILE\.ssh\strato_fewo"
|
|
$SshTarget = "stu100093250@51539426.ssh.w1.strato.hosting"
|
|
$WikiDir = "Karate_Wiki_135"
|
|
|
|
$BackupDir = Join-Path $PSScriptRoot "..\backups\db-init"
|
|
New-Item -ItemType Directory -Force -Path $BackupDir | Out-Null
|
|
|
|
Write-Host "1. Erstelle rein lesenden Datenbank-Dump von Strato nach backups\db-init\01-karatewiki.sql ..." -ForegroundColor Cyan
|
|
$RemoteDumpCmd = @'
|
|
/opt/RZphp84/bin/php-cli -r '
|
|
$c = file_get_contents("Karate_Wiki_135/LocalSettings.php");
|
|
preg_match("/wgDBpassword\s*=\s*\"([^\"]+)\"/", $c, $m);
|
|
$cmd = sprintf("mysqldump --single-transaction --no-tablespaces -h rdbms.strato.de -u dbu1061679 -p%s dbs1754262", escapeshellarg($m[1]));
|
|
passthru($cmd);
|
|
'
|
|
'@
|
|
|
|
ssh -i $SshKey -o BatchMode=yes $SshTarget $RemoteDumpCmd > (Join-Path $BackupDir "01-karatewiki.sql")
|
|
Write-Host " Datenbank-Dump erfolgreich gespeichert!" -ForegroundColor Green
|
|
|
|
if ($IncludeSampleVideos) {
|
|
$ImagesDir = Join-Path $PSScriptRoot "..\data\images"
|
|
New-Item -ItemType Directory -Force -Path $ImagesDir | Out-Null
|
|
Write-Host "2. Kopiere images/ Verzeichnis (oder Beispiel-Videos) ..." -ForegroundColor Cyan
|
|
scp -i $SshKey -r "${SshTarget}:${WikiDir}/images/.htaccess" $ImagesDir
|
|
}
|