pgsql 自动备份和恢复
window
自动备份
@echo off
SET PGPASSWORD=postgres
SET timestamp=%Date:~0,4%%Date:~5,2%%Date:~8,2%%Date:~8,2%%Time:~3,2%
SET backup_dir=D:/postgres/%timestamp%
echo %backup_dir%
"C:/Program Files/PostgreSQL/15/bin/pg_dump.exe" -U postgres -h localhost -p 5432 -F t -b -v -f "%backup_dir%_database_backup.tar" devdb
echo done
恢复
@echo off
SET PGPASSWORD=postgres
"C:/Program Files/PostgreSQL/15/bin/pg_restore.exe" -U postgres -h localhost -p 5432 -F t -v -d wonderhalo-wms D:/postgres/202306191955_database_backup.tar