Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize automatic backup of PostgreSQL in Windows

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

Today, I will talk to you about how to achieve automatic backup of PostgreSQL in Windows. Many people may not know much about it. In order to make you understand better, the editor has summarized the following content for you. I hope you can get something according to this article.

* step:

Download the batch file.

Step 2:

You can use a simple command (schtasks /? View help) or use the graphical interface (start-Control Panel-system and Security-Administration tools-Task Scheduler) to run the task schedule management tool, or you can start it by double-clicking Taskschd.msc in the% SYSTEMROOT%\ System32 directory.

Step 3:

You can create basic tasks by importing information through wizards or through XML files. For the wizard creation method, see the Task Scheduler help. The following command line syntax is described below:

Schtasks / Create [/ S [/ U [/ P [] [/ RU [/ RP]] / SC [/ MO] [/ D] [/ M] [/ I] / TN / TR [/ ST] [/ RI] [{/ ET | / DU} [/ K] [/ XML] [/ V1] [/ SD] [/ ED] [/ IT] [/ Z] [/ F]

View this command help:

Schtasks / Create /?

If remote task scheduling management is disabled and file and print sharing is enabled and the remote registry service is running in Windows Firewall, a V1 task will be created on the remote computer even without the parameter V1. Parameter V1 indicates that a task is visible to the underlying system.

Use the code

Script:

@ ECHO OFF @ setlocal enableextensions@cd / d "% ~ dp0" SET PGPATH=C:\ "Program Files"\ PostgreSQL\ 9.1\ bin\ SET SVPATH=f:\ SET PRJDB=demo SET DBUSR=postgres FOR / F "TOKENS=1,2,3 DELIMS=/"% I IN ('DATE / T') DO SET d=%%i-%%j-%%k FOR / F "TOKENS=1,2 3 DELIMS=: "I IN ('TIME / T') DO SET t=%%i%%j%%k SET DBDUMP=%PRJDB%_%d%_%t%.sql@ECHO OFF PGPATH%pg_dump-h localhost-p 5432-U postgres PRJDB% > SVPATH%%DBDUMP% 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 user name

After reading the above, do you have any further understanding of how to achieve automatic PostgreSQL backup in Windows? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report