Solved

Windows PowerShell - BackUp Postgre Dbase

Posted on 2009-03-30
4
1,879 Views
Last Modified: 2012-08-13
Hi,

I would like to ask if anyone knows how to backup postgre dbase using windows powershell and automate it to be done once a month.

Thanks.
0
Comment
Question by:openaccount1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 62

Expert Comment

by:gheist
ID: 24023578
Powershell does nothing once a month. You need another scheduler. PostgreSQL really does not care if pg_dumpall is ran from powershell or from cmd file or from atsvc directly.
0
 

Author Comment

by:openaccount1
ID: 24037145
ok say we use windows scheduler for the schedule. How can we backup our Dbases? Our service provider says that we can use the code below as a sample but I do not know anything about powershell. Can you explain the code below and how we can use it with windows scheduler?


set-item -force -path env:PGPASSWORD -value actualpassword
 
$pgdbs = "db1","db2","db3"
 
Foreach ($db in $pgdbs) {
 
                & 'C:\Program Files\PostgreSQL\8.3\bin\pg_dump.exe' -Fc -U username -f "path-to-backup-temp" $db
 
                remove-item "path-to-permanentbackup\pgdump$db"
 
                move-item "path-to-permanentbackup\pgdump$db" "path-to-backup-temp\pgdump$db"
 
}

Open in new window

0
 
LVL 62

Accepted Solution

by:
gheist earned 500 total points
ID: 24038257
It backs up all $pgdbs in background in parallel.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question