备份数据
octoplant 系统提供手动备份服务器存档数据的选项,或使用批处理文件定期自动备份的选项。
前提条件
要执行服务器存档数据备份,必须满足以下强制性 先决条件:
Warning
如果不满足这些要求,服务器存档可能会被破坏,数据也可能会丢失。
- 执行备份的用户必须拥有服务器的管理员权限。
- 在开始备份之前,请停止VDog MasterService 。您可以在服务控制管理器中进行验证。
- 停止VDog MasterService 也会停止PostgreSQL Server (
PostgreSQL.exe
应用程序)。 - 终止所有从属VDog MasterService 进程。本主题](../../../0040_AboutProduct/0010_AboutProductName/0010_SystemStructure.md)中提供了完整列表。
- 使用任务管理器 >进程 确认所有PostgreSQL 服务器 和VDog MasterService 进程都已终止。
Info
数据备份期间,系统不可用。建议在夜间或周末等非高峰时段执行数据备份。
节省存储空间
- 服务器存档的
VD_TMP_VD
目录只包含临时文件。备份服务器存档时,请不要备份VD_TMP_VD
目录。 - 在备份之前,可以对
vdServerArchive
目录进行压缩。为了进行压缩,必须安装相应的 ZIP 应用程序。
手动备份数据
Warning
如果使用远程存档,必须始终同时备份远程存档和本地服务器存档。
本地存档
将本地目录 vdServerArchive
复制到所需的存储位置,如外部硬盘。
远程存档
将远程共享的 vdServerArchive
目录复制到所需的存储位置,如外部硬盘。
自动备份数据
您可以通过创建批处理文件并使用 Windows 作业调度器在特定时间执行该文件,自动备份 vdServerArchive
目录。
Info
不建议在已安装 octoplant 服务器的计算机上安装 octoplant hub。如果已经安装,则除了 VDog MasterService 外,还必须在批处理文件中终止并随后重启 octoplant hub 服务 octoplanthub-postgres
和 octoplanthubsvc
。您可以在本页底部找到带有 octoplant hub 的 Backup.bat
文件示例。
示例:Backup.bat 文件
Info
要将示例中的批处理文件用于您的系统,请根据您的系统调整文件中的所有路径规格。
set SERVERARCHIVE="D:\vdServerArchive\*"
rem If no remote archive, set the variable remotearchive to an empty value.
rem set REMOTEARCHIVE=""
set REMOTEARCHIVE="\\storage\share\vdServerArchive\*"
set OUTFILE="D:\vdServerBackup.zip"
set 7ZIP="%PROGRAMFILES(x86)%\7-Zip\7z.exe"
net stop "VDog MasterService"
if NOT "%ERRORLEVEL%"=="0" (
if NOT "%ERRORLEVEL%"=="2" (
echo Could not stop server
exit /B %ERRORLEVEL%
)
)
tasklist /fi "ImageName eq VDog*" /fo csv 2>NUL | find /I "VDog">NUL
if "%ERRORLEVEL%"=="0" (
echo Server processes still running
tasklist /fi "ImageName eq VDog*" /fo csv
exit /B 1
)
tasklist /fi "ImageName eq postgres.exe" /fo csv 2>NUL | find /I "postgres.exe">NUL
if "%ERRORLEVEL%"=="0" (
tasklist /fi "ImageName eq postgres.exe" /fo csv
echo Database processes still running
exit /B 1
)
REM Backup local server archive with 7-zip
"%7ZIP%" u -t7z -r %OUTFILE% %SERVERARCHIVE%
if NOT "%ERRORLEVEL%"=="0" (
echo Could not zip server archive
exit /B %ERRORLEVEL%
)
if "%REMOTEARCHIVE%" == "" GOTO startms
REM Backup remote server archive with 7-zip
"%7ZIP%" u -t7z -r %OUTFILE% %REMOTEARCHIVE%
if NOT "%ERRORLEVEL%"=="0" (
echo Could not zip remote archive
exit /B %ERRORLEVEL%
)
:startms
net start "VDog MasterService"
if NOT "%ERRORLEVEL%"=="0" (
echo Could not start server
exit /B %ERRORLEVEL%
)
echo "success"
pause
Backup.bat 文件示例(含 octoplant hub)
set SERVERARCHIVE="D:\vdServerArchive\*"
rem If no remote archive, set the variable remotearchive to an empty value.
rem set REMOTEARCHIVE=""
set REMOTEARCHIVE="\\storage\share\vdServerArchive\*"
set OUTFILE="D:\vdServerBackup.zip"
set 7ZIP="%PROGRAMFILES(x86)%\7-Zip\7z.exe"
echo Stopping server
net stop "VDog MasterService"
if NOT "%ERRORLEVEL%"=="0" (
if NOT "%ERRORLEVEL%"=="2" (
echo Could not stop server
exit /B %ERRORLEVEL%
)
)
echo Stopping hub database
net stop "octoplanthub-postgres"
if NOT "%ERRORLEVEL%"=="0" (
if NOT "%ERRORLEVEL%"=="2" (
echo Could not stop hub database
exit /B %ERRORLEVEL%
)
)
echo Stopping hub
net stop "octoplanthubsvc"
if NOT "%ERRORLEVEL%"=="0" (
if NOT "%ERRORLEVEL%"=="2" (
echo Could not stop hub
exit /B %ERRORLEVEL%
)
)
tasklist /fi "ImageName eq VDog*" /fo csv 2>NUL | find /I "VDog">NUL
if "%ERRORLEVEL%"=="0" (
echo Server Processes still running
tasklist /fi "ImageName eq VDog*" /fo csv
exit /B 1
)
tasklist /fi "ImageName eq postgres.exe" /fo csv 2>NUL | find /I "postgres.exe">NUL
if "%ERRORLEVEL%"=="0" (
tasklist /fi "ImageName eq postgres.exe" /fo csv
echo Database Processes still running
exit /B 1
REM Backup local server archive with 7-zip
%7ZIP% u -t7z -r %OUTFILE% %SERVERARCHIVE%
if NOT "%ERRORLEVEL%"=="0" (
echo Could not zip server archive
exit /B %ERRORLEVEL%
)
if "%REMOTEARCHIVE%" == "" GOTO startms
REM Backup remote server archive with 7-zip
%7ZIP% u -t7z -r %OUTFILE% %REMOTEARCHIVE%
if NOT "%ERRORLEVEL%"=="0" (
echo Could not zip remote archive
exit /B %ERRORLEVEL%
)
:startms
echo Starting server
net start "VDog MasterService"
if NOT "%ERRORLEVEL%"=="0" (
echo Could not start server
exit /B %ERRORLEVEL%
)
echo Starting hub database
net start "octoplanthub-postgres"
if NOT "%ERRORLEVEL%"=="0" (
echo Could not start hub database
exit /B %ERRORLEVEL%
)
echo Starting hub
net start "octoplanthubsvc"
if NOT "%ERRORLEVEL%"=="0" (
echo Could not start hub
exit /B %ERRORLEVEL%
)
echo "success"
pause