美文网首页
postgre数据库自动备份并删除30天之前的数据

postgre数据库自动备份并删除30天之前的数据

作者: S等价交换S | 来源:发表于2021-10-18 13:35 被阅读0次

    版本

    postgre数据库

    pgadmin4

    @echo off

    for /f "tokens=1-4 delims=/ " %%i in ("%date%") do (

    set year=%%i

    set month=%%j

    set day=%%k

    set dow=%%l

    )

    set datestr=%year%_%month%_%day%

    echo datestr is %datestr%

    SET SAVEPATH=D:\java\test\

    SET PGPATH=D:\java\postgresql\bin\

    SET PGUSER=postgres

    SET PGPASSWORD=123456

    SET PGDB=rydw

    set BACKUP_FILE=%SAVEPATH%%PGDB%_%datestr%.backup

    echo backup file is %BACKUP_FILE%

    echo on

    D:

    %PGPATH%pg_dump -h localhost -p 5432 -U %PGUSER% -F c -b -v -f %BACKUP_FILE% %PGDB%

    @echo Backup Completed.

    @echo Backup File: %BACKUP_FILE%

    forfiles /p %SAVEPATH% /m *.backup /d -30 /c "cmd /c del @path"

    相关文章

      网友评论

          本文标题:postgre数据库自动备份并删除30天之前的数据

          本文链接:https://www.haomeiwen.com/subject/sqpboltx.html