Windows PostgreSQL timed backup does not require a password to be entered manually

Source: Internet
Author: User
Tags postgresql


PostgreSQL automatically backs up and deletes Windows scripts for backup files 10 days ago.


The first step, create the script, name the Back.bat file

@ECHO OFF
@setlocal enableextensions
@cd / d "% ~ dp0"
 
set PGPASSWORD = password
SET PGPATH = D: \ postgresql \ bin \
SET SVPATH = d: \ zoobackup \
SET PRJDB = gzzoo
SET DBUSR = postgres
FOR / F "TOKENS = 1,2,3 DELIMS = /" %% i IN (‘DATE / T’) DO SET d = %% i-%% j-%% k
 
SET DBDUMP =% PRJDB% _% d% .bak
@ECHO OFF
% PGPATH% pg_dump -h localhost -U postgres% PRJDB%>% SVPATH %% DBDUMP%

echo Backup Taken Complete% SVPATH %% DBDUMP%

forfiles / p% SVPATH% / d -5 / c "cmd / c echo deleting @file ... && del / f @path"
Among them: PGPASSWORD password, PGPATH database path, SVPATH backup file storage location, PRJDB database name, DBUSR user name

 

Step 2 Set up scheduled tasks

https://www.cnblogs.com/franknihao/p/7120851.html
 
 
 
 
Windows postgresql regular backup, no need to manually enter the password

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.