Hello,
I am using the openkm/openkm-ce docker image. I did set it up to work with a MSSQL in a docker container.
Now I wrote a backup script that is doing a daily backup for me. Backing up database works. Zipping and backing up repository works in my DEV.
But I have one problem. Whenever I want to stop the tomcat in the container is says that there is no PID file.
I think I am root if I use docker cli. So it should not be a privilge issue.
Can you please let me know how to shut down tomcat before doing backups and how to restart it afterwards.
Thanks a lot.
BTW. This is my backup PowerShell script:
I am using the openkm/openkm-ce docker image. I did set it up to work with a MSSQL in a docker container.
Now I wrote a backup script that is doing a daily backup for me. Backing up database works. Zipping and backing up repository works in my DEV.
But I have one problem. Whenever I want to stop the tomcat in the container is says that there is no PID file.
I think I am root if I use docker cli. So it should not be a privilge issue.
Can you please let me know how to shut down tomcat before doing backups and how to restart it afterwards.
Thanks a lot.
BTW. This is my backup PowerShell script:
Code: Select all
$date = Get-Date
$dateString = (Get-Date -f yyyy-MM-dd_HHmmss)
$uncServer = "\\192.168.10.10"
$uncFullPath = "$uncServer\OpenKM DB Backup"
$uncMonthlyDir = "monthly"
$uncWeeklyDir = "weekly"
$uncDailyDir = "daily"
$username = "Diskstation\xxx"
$password = "yyy"
iex "docker exec -it mssql1 /opt/mssql-tools/bin/sqlcmd -S localhost -U SA -P `"xxx`" -Q `"BACKUP DATABASE [OpenKM] TO DISK = N'/var/opt/mssql/backup/openkm.bak' WITH NOFORMAT, INIT, NAME = 'OpenKM-full', SKIP, NOREWIND, NOUNLOAD, STATS = 10`""
iex "docker cp mssql1:/var/opt/mssql/backup/openkm.bak openkm_$dateString.bak"
iex "docker exec -it openkm-ce zip -r /opt/openkm/backup/repository_$dateString.zip /opt/openkm/repository/"
iex "docker cp openkm-ce:/opt/openkm/backup/repository_$dateString.zip repository_$dateString.zip"
iex "docker exec -it openkm-ce rm /opt/openkm/backup/repository_$dateString.zip"
net use $uncServer $password /USER:$username
try
{
if ($date.Day -eq 1) {
if (-not (Test-Path -LiteralPath "$uncFullPath\$uncMonthlyDir")) {
New-Item -Path "$uncFullPath" -Name "$uncMonthlyDir" -ItemType "directory"
}
Copy-Item "openkm_$dateString.bak" "$uncFullPath\$uncMonthlyDir\openkm_$dateString.bak"
Copy-Item "repository_$dateString.zip" "$uncFullPath\$uncMonthlyDir\repository_$dateString.zip"
Get-ChildItem "$uncFullPath\$uncMonthlyDir\" |? {$_.lastwritetime -le (Get-Date).AddMonths(-1)} |% {Remove-Item $_ -force }
}elseif ([int] $date.DayOfWeek -eq 0) {
if (-not (Test-Path -LiteralPath "$uncFullPath\$uncWeeklyDir")) {
New-Item -Path "$uncFullPath" -Name "$uncWeeklyDir" -ItemType "directory"
}
Copy-Item "openkm_$dateString.bak" "$uncFullPath\$uncWeeklyDir\openkm_$dateString.bak"
Copy-Item "repository_$dateString.zip" "$uncFullPath\$uncWeeklyDir\repository_$dateString.zip"
Get-ChildItem "$uncFullPath\$uncWeeklyDir\" |? {$_.lastwritetime -le (Get-Date).AddMonths(-1)} |% {Remove-Item $_ -force }
} else {
if (-not (Test-Path -LiteralPath "$uncFullPath\$uncDailyDir")) {
New-Item -Path "$uncFullPath" -Name "$uncDailyDir" -ItemType "directory"
}
Copy-Item "openkm_$dateString.bak" "$uncFullPath\$uncDailyDir\openkm_$dateString.bak"
Copy-Item "repository_$dateString.zip" "$uncFullPath\$uncDailyDir\repository_$dateString.zip"
Get-ChildItem "$uncFullPath\$uncDailyDir\" |? {$_.lastwritetime -le (Get-Date).AddDays(-8)} |% {Remove-Item $_ -force }
}
}
catch [System.Exception] {
$pw = Get-Content .\MailPW.txt | ConvertTo-SecureString
$cred = New-Object System.Management.Automation.PSCredential "oengst@engst.de", $pw
Send-MailMessage -Credential $cred -to "oengst@engst.de" -from "oengst@engst.de" -subject "Error OpenKM Backup" -SmtpServer "smtp.strato.de" -UseSSL
}
finally {
net use $uncServer /delete
}