Solved

Windows PowerShell - BackUp Postgre Dbase

Posted on 2009-03-30
4
1,903 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

A procedure for exporting installed hotfix details of remote computers using powershell
A brief introduction to what I consider to be the best editor for PowerShell.
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…

691 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