nixCraft Linux Forum

nixCraft

Linux / UNIX Tech Support Forum

Postgres backup

This is a discussion on Postgres backup within the Databases servers forums, part of the Mastering Servers category; Hai, How do I make a backup under postgres database server? Under mysql I can use mysqldump.. what about pgsql ...


Go Back   nixCraft Linux Forum > Mastering Servers > Databases servers

Linux answers from nixCraft.


Databases servers Discussions of databases of all types - especially MySQL.

Reply

 

LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-01-2007, 05:45 PM
chiku's Avatar
Member
User
 
Join Date: Feb 2005
OS: Fedora
Posts: 86
Thanks: 10
Thanked 0 Times in 0 Posts
Rep Power: 0
chiku is on a distinguished road
Default Postgres backup

Hai,

How do I make a backup under postgres database server? Under mysql I can use mysqldump.. what about pgsql ??? any idea what command i need to use. Also specify script if possible.

TIA
__________________
There's no place like 127.0.0.1
Reply With Quote
  #2 (permalink)  
Old 03-01-2007, 06:31 PM
rockdalinux's Avatar
Is that all you got?
User
 
Join Date: May 2005
Location: Planet Vegeta
OS: Redhat
Posts: 708
Thanks: 15
Thanked 19 Times in 18 Posts
Rep Power: 10
rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light rockdalinux is a glorious beacon of light
Default

Here is my postgres (pgsql) backup script:

Code:
#!/bin/sh
# Bak dump dir - Change me
BACKUP="/backup"
# get list of dbs
PGDBS=$(psql -h localhost -U postgres -q -c "\l" | sed -n 4,/\eof/p | grep -v rows\) | awk {'print $1'})

for d in $PGDBS; do
        NOW=`date '+%T %x'`
        vacuumdb -z -h localhost -U postgres $d
        pg_dump $d -h localhost | gzip > "$BACKUP/postgresql-$d-$NOW.gz"
done
Run script as postgres or root user. Cron job:
Code:
03 05 * * * /path/to/pgsql.backup.sh > /dev/null 2>&1
__________________
Rocky Jr.
What's wrong? I hope I am not making you uncomfortable...

Never send a boy to do a mans job.
Reply With Quote
  #3 (permalink)  
Old 03-01-2007, 09:43 PM
nixcraft's Avatar
Never say die
User
 
Join Date: Jan 2005
Location: BIOS
OS: RHEL
Scripting language: Bash and Python
Posts: 2,710
Thanks: 11
Thanked 245 Times in 184 Posts
Rep Power: 10
nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute nixcraft has a reputation beyond repute
Default

Also see Howto Backup PostgreSQL Databases for more info about commands.
__________________
Vivek Gite
Linux Evangelist
Be proud RHEL user, and let the world know about your enterprise choices! Join RedHat user group.
Always use CODE tags for posting system output and commands!
Do you run a Linux? Let's face it, you need help
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 
Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Postgres idle connections kasimani Databases servers 1 14-05-2007 05:58 PM
Postgres vacuumdb usage kasimani Databases servers 2 06-03-2007 07:30 AM


All times are GMT +5.5. The time now is 10:48 PM.


Powered by vBulletin® Version 3.8.5 - Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.2
©2005-2010 nixCraft. All rights reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38