Implement PostgreSQL automatic backup in Windows _ MySQL-mysql tutorial

Source: Internet
Author: User
Tags schtasks
PostgreSQL automatically backs up bitsCN.com in Windows

This article describes how to create a Windows batch processing file to automatically back up the PostgreSQL database. Background an automated system is required for my work on a PostgreSQL database project to perform backups every day. After some research, we decided to create a Windows batch processing file and add it to the Windows scheduled task. The following describes how to configure the first step: Download a batch file. Step 2: You can use a simple command (schtasks /? View help) or use a graphical interface (start-control panel-system and security-management tools-Task Scheduler) to run the task scheduler management tool, you can also double-click Taskschd in the % SYSTEMROOT %/System32 directory. msc to start it. Step 3: You can use a wizard or XML file to import information to create a basic task. For how to Create a wizard, see the task scheduler help. The following describes the Command Line Syntax: 1 schtasks/Create [/S [/U [/P [ ] 2 [/RU [/RP ]/SC [/MO ] [/D ] 3 [/M ] [/I ]/TN /TR [/ST ] 4 [/RI ] [{/ET |/DU } [/K] [/XML ] [/V1] 5 [/SD ] [/ED ] [/IT] [/Z] [/F]

View the help of this command: 1 schtasks/Create /?

If remote Task Scheduler management is disabled in Windows Firewall, file and print sharing are enabled, and the remote registry service is running, a V1 task is created on the remote computer even if the parameter V1 is not used. The V1 parameter indicates that a task is visible to the lower-level system. Run the code script: 01 @ ECHO OFF02 @ setlocal enableextensions @ cd/d "% ~ Dp0 "03 04 set pgpath = C:/" Program Files "/PostgreSQL/9.1/bin/05 set svpath = f: /06 set prjdb = demo07SET DBUSR = ipvs08for/F "TOKENS = 1, 2, 3 DELIMS =/" % I IN ('date/t ') do set d = % I-% j-% k09FOR/F "TOKENS = 1, 2, 3 DELIMS =:" % I IN ('Time/t ') do set t = % I % j % k10 11 SET DBDUMP = % PRJDB % _ % d % _ % t %. SQL @ ECHO OFF12 % PGPATH % pg_dump-h localhost-p 5432-U postgres % PRJDB %> % SVPATH % DBDUMP % 13 14 echo Backup Taken Complete % SVPATH % DBDUMP %

Initial value
  • PGPATH-PostgreSQL path
  • SVPATH-backup file path
  • PRJDB-name of the database to be backed up
  • DBUSR-database username
BitsCN.com

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.