1)使用环境变量来存储密码
setx KINGBASE_PASSWORD "abc123"
2)编写backup.bat
:: 设置备份参数
set "sys_dump=c:\Program Files\Kingbase\ES\V8\KESRealPro\V008R006C008B0014\ClientTools\bin\sys_dump"
set "host=localhost"
set "port=54321"
set "user=system"
set "dbname=platform"
set "ymd=%date:~,4%%date:~5,2%%date:~8,2%"
set "hms=%time:~0,2%%time:~3,2%%time:~6,2%"
set "backupdir=C:\db_back\Kingbase"
:: 执行备份命令
"%sys_dump%" -h %host% -p %port% -U %user% -v -f "%backupdir%\%dbname%_%ymd%%hms%.dmp" -F c %dbname%
:: 检查备份是否成功
if %errorlevel% equ 0 (
echo Backup completed successfully!
) else (
echo Backup failed!
)