PostgreSQL Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesPostgreSQL Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old April 12th, 2006, 09:43 AM
tariqf tariqf is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2006
Posts: 1 tariqf User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 14 m 33 sec
Reputation Power: 0
Restore/use databse from data file backup

I need to restore some data from yesterday into my postgres database. I only have a filesystem backup each night so I have the full contents of /var/lib/pgsql which contains data, base, global etc. etc.

How do I copy my backup database folder into my currently running or maybe a spare server so that I can query yesterdays data to export back into the current db?

I think my databse is /var/lib/pgsql/data/base/156814 and my backup is on /mnt/buffalo/daily.0/var/lib/pgsql/data/base/156814

Please please can someone help it's pretty urgent!

Thanks in advance

Reply With Quote
  #2  
Old April 12th, 2006, 01:04 PM
rycamor rycamor is offline
Gödelian monster
Dev Shed Regular (2000 - 2499 posts)
 
Join Date: Jul 1999
Location: Central Florida, USA
Posts: 2,304 rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level)rycamor User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 3 Days 5 h 17 m 20 sec
Reputation Power: 56
Quote:
Originally Posted by tariqf
I need to restore some data from yesterday into my postgres database. I only have a filesystem backup each night so I have the full contents of /var/lib/pgsql which contains data, base, global etc. etc.

How do I copy my backup database folder into my currently running or maybe a spare server so that I can query yesterdays data to export back into the current db?


You *never* copy your backup data directory into your currently running PostgreSQL directory. That's a perfect path to disaster. There is one and only one way that might (might) help you:

1. Stop the postgreSQL service
2. Make a complete backup of your *existing* postgreSQL data folder. Be very careful that this is a full backup.
3. Remove your existing data folder, and copy your backup folder back into place. This means your *complete* backup of your data directory, not just the particular location that you think might be your database (/mnt/buffalo/daily.0/var/lib/pgsql/data/base/156814)
4. Start PostgreSQL running again, and do a complete pg_dump of the database you are trying to rescue.*
5. Stop the PostgreSQL service again
6. Remove the older version of your data directory, and restore your current copy into place.
7. Start PostgreSQL and then begin trying to merge your pg_dump records with your current copy of the database.

*Note that I can't promise you the the backed up data directory has perfect data integrity. Simply copying your data folder while PostgreSQL is running is a bad practice and can result in corrupt backups. The only right way to backup PostgreSQL is to run pg_dump regularly.
__________________
The real n-tier system:

FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

Amazon wishlist -- rycamor (at) gmail.com

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesPostgreSQL Help > Restore/use databse from data file backup


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump



 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT