LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 10-08-2008, 10:34 PM   #1
noir911
Member
 
Registered: Apr 2004
Posts: 682

Rep: Reputation: Disabled
review postgres dump script and difference between pg_dump & pg_dumpall


I have written the following script to backup _all_ databases on
various servers that are running postgresql. I don't want anything
fancy - just be able to backup the database and restore when bad times
come. Just posting it here to be reviewed to see if I have made any
mistake:

Code:
#!/bin/bash
DIR=/backup
[ ! $DIR ] && mkdir -p $DIR || :
# ignore any name starting with ---, List, Name, ( or template 0 and 1
LIST=$(psql -l | awk '{ print $1}' | grep -vE
'^-|^List|^Name|^\(|template[0|1]')
for d in $LIST
do
 pg_dump $d | gzip -c >  $DIR/$d.out.postgres.`hostname`.gz
done
I am running this script from the user "postgres" crontab.

Also, I have read the respective manpages but never understood the
difference between pg_dump & pg_dumpall. But I noticed pg_dumpall
dumps the schema (?) and pg_dump dumps the actual tables and rows etc.

Thanks.
 
Old 10-09-2008, 10:11 AM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
Actually pg_dumpall calls pg_dump and is just a single command to create a backup for all databases. pg_dumpall dumps global objects but pg_dump does not. pg_dump can dump data and schemas.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
shell script to find the difference betwwn two file and place the difference to other kittunot4u Linux - General 3 07-19-2010 04:26 AM
Postgres encoding restore dump problem milescook Linux - Server 16 08-27-2008 01:15 PM
difference between shell script & make subbusp2 Linux - Newbie 1 07-23-2008 09:33 PM
Difference between executing & sourcing a script muazfarooqaslam Linux - Newbie 1 01-04-2008 02:51 AM
postgres dump needed help. vickr1z Linux - Newbie 3 11-10-2004 03:22 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:09 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration