Solved

Windows PowerShell - BackUp Postgre Dbase

Posted on 2009-03-30
4
1,698 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
  • 2
4 Comments
 
LVL 61

Expert Comment

by:gheist
Comment Utility
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
Comment Utility
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 61

Accepted Solution

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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

The article will show you how you can maintain a simple logfile of all Startup and Shutdown events on Windows servers and desktops with PowerShell. The script can be easily adapted into doing more like gracefully silencing/updating your monitoring s…
Create and license users in Office 365 in bulk based on a CSV file. A step-by-step guide with PowerShell script examples.
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now