Solved

Windows PowerShell - BackUp Postgre Dbase

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

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…
Synchronize a new Active Directory domain with an existing Office 365 tenant
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…

809 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