Service Neo4j v2停止windows服务-检测到非清洁关机

Service Neo4j v2停止windows服务-检测到非清洁关机,service,cmd,neo4j,backup,shutdown,Service,Cmd,Neo4j,Backup,Shutdown,如何正确地干净地停止Neo4j Windows服务?我有Neo4j(v2-社区)作为windows服务运行。我要做的是备份数据文件 目前我已经写了一个批处理文件,将。。。 -关闭服务 -备份数据文件 -重新启动服务 问题是,在重新启动服务并检查日志文件后,会记录以下消息(见下文)-尽管数据库已恢复,但我担心在某些情况下,它可能会由于“非干净关机”而损坏 下面是批处理文件本身 @echo off rem Batch file to backup Neo4j data files rem Accep

如何正确地干净地停止Neo4j Windows服务?我有Neo4j(v2-社区)作为windows服务运行。我要做的是备份数据文件

目前我已经写了一个批处理文件,将。。。 -关闭服务 -备份数据文件 -重新启动服务

问题是,在重新启动服务并检查日志文件后,会记录以下消息(见下文)-尽管数据库已恢复,但我担心在某些情况下,它可能会由于“非干净关机”而损坏

下面是批处理文件本身

@echo off
rem Batch file to backup Neo4j data files
rem Accepts one parameter [prod|qa] which is the name of the folder to backup

set instance=%1%
set services=E:\neo4j\%instance%\
set source_path=F:\neo4j\%instance%\data
set destination_path=E:\neo4j_data_backups\%instance%\%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%
set robocopy_log_file=E:\neo4j_data_backups\%instance%\backup_%date:~10,4%%date:~4,2%%date:~7,2%.log

rem check to make sure the source folder exists - otherwise quit
if not exist %source_path% goto :badargument

rem if call "%services%bin\Neo4jInstaller.bat" status == "RUNNING"

rem Stop the Neo4j Service before the backup
echo Stopping service: Neo4j-Server-%instance%
sc stop Neo4j-Server-%instance%

rem Copy the data folder
echo Backing up data from %source_path% to %destination_path%
robocopy %source_path% %destination_path% /E /LOG+:%robocopy_log_file%

rem Start the Neo4j Service again after the data backup
echo Starting service: Neo4j-Server-%instance%
sc start Neo4j-Server-%instance%

rem lets zip the file now
echo Zipping the backup content: %destination_path%.zip
7z a -tzip %destination_path%.zip %destination_path% > NUL:

rem delete the backup folder
echo Deleting the backup folder after zip
rd /s/q %destination_path%

echo #### Backup Completed ####
goto :eof

我假设您正在重新启动Windows主机服务,这可能会在重新启动之前杀死Neo4j数据库进程。主机服务需要等待关闭过程完成并将可用堆写入磁盘。请提供批处理文件源。Hey@KennyBastani-我正在使用批处理文件中提到的停止服务命令(sc)(请参阅更新信息)-这是基于指南[link]-只是为了清除“非干净关机”消息在windows服务重新启动时实际被记录
@echo off
rem Batch file to backup Neo4j data files
rem Accepts one parameter [prod|qa] which is the name of the folder to backup

set instance=%1%
set services=E:\neo4j\%instance%\
set source_path=F:\neo4j\%instance%\data
set destination_path=E:\neo4j_data_backups\%instance%\%date:~10,4%%date:~4,2%%date:~7,2%_%time:~0,2%%time:~3,2%
set robocopy_log_file=E:\neo4j_data_backups\%instance%\backup_%date:~10,4%%date:~4,2%%date:~7,2%.log

rem check to make sure the source folder exists - otherwise quit
if not exist %source_path% goto :badargument

rem if call "%services%bin\Neo4jInstaller.bat" status == "RUNNING"

rem Stop the Neo4j Service before the backup
echo Stopping service: Neo4j-Server-%instance%
sc stop Neo4j-Server-%instance%

rem Copy the data folder
echo Backing up data from %source_path% to %destination_path%
robocopy %source_path% %destination_path% /E /LOG+:%robocopy_log_file%

rem Start the Neo4j Service again after the data backup
echo Starting service: Neo4j-Server-%instance%
sc start Neo4j-Server-%instance%

rem lets zip the file now
echo Zipping the backup content: %destination_path%.zip
7z a -tzip %destination_path%.zip %destination_path% > NUL:

rem delete the backup folder
echo Deleting the backup folder after zip
rd /s/q %destination_path%

echo #### Backup Completed ####
goto :eof