Copying DBs?

PostgreSQL is the database server used to store information. Do you have a question or are you having problem with PostgreSQL? If so, post them here.

Moderator: Moderators

Copying DBs?

Postby onthehustle » Sat Sep 05, 2009 9:21 pm

I have several million hand spread across several DBs in 2 month increments (20 mil+). The DBs and Postgres are installed/reside on an external HD. My time is up on my current HD and bought a spanking new 1TB external.

Would it be possible to do a bit for bit copy of the existing external HD and install the backup on the new external HD with a program like acronis or driveimage and swap the data seemlessly?

Could I install Postgres on the new external HD along with the backup stat/hud files and such then paste the folders housing the DBs from the old external then in DB management browse for and find the old DBs?

If the 2 options above won't work then what would be the least painful way to acomplish the move?

Thx
onthehustle
 
Posts: 54
Joined: Sat Nov 15, 2008 6:52 pm

Re: Copying DBs?

Postby WhiteRider » Sun Sep 06, 2009 4:31 am

I'm pretty sure you'll need to re-install postgres rather than just copying the drive image, although someone may correct me on that.
Either way, you should make a backup of your databases before trying anything. Once you've done that you will always be able to recover them once you have postgres set up again.
See the Database / Postgres FAQ for a step by step backup guide. This thread also has links to posts about different ways of setting up / moving databases on different drives.

If you need further help please post back - kraada will be on later and he knows more about postgres setups than I do.
WhiteRider
Moderator
 
Posts: 54018
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK

Re: Copying DBs?

Postby kraada » Sun Sep 06, 2009 8:47 am

If you're using the external drive on the same system, a bit for bit copy, followed by a partition resizing, should do the trick, just make sure that the PostgreSQL server is stopped at the time you do the copy. The other method of backing up/reinstalling/restoring the database will certainly work as well, and honestly it might well be faster depending on how much other stuff you have on the hard drive (and then as a bonus you have a backup of your database). But the drive image will work so long as you have PostgreSQL completely stopped.
kraada
Moderator
 
Posts: 54431
Joined: Wed Mar 05, 2008 2:32 am
Location: NY

Re: Copying DBs?

Postby onthehustle » Sun Sep 06, 2009 10:34 pm

Might try the bit for bit image first. The original external is 320gig with 307 used so maybe a compressed bit-bit might be faster. I'll let you know how it works. Thx
onthehustle
 
Posts: 54
Joined: Sat Nov 15, 2008 6:52 pm

Re: Copying DBs?

Postby onthehustle » Sat Dec 12, 2009 2:51 am

Thought I'd take the time to follow up. What I ended up doing, which was also the fastest and most successful, was the following:

The external drive had a label of E

I left the old HD in E and set up the new external HD in F

Formatted the new HD in ntfs

I shut down Postgres (which runs on the external not my main drive)

Ran built in window pro backup and send the backup file to the new drive on F

When complete shut down and pulled on the old HD and left the new

I then set the new HD label to E to match the old (this was key)

Restored the backup and bada bing bada boom, Done

Moved 230 gigs of HHs to the new terabyte HD in about 12 hours.
onthehustle
 
Posts: 54
Joined: Sat Nov 15, 2008 6:52 pm

Re: Copying DBs?

Postby WhiteRider » Sat Dec 12, 2009 6:53 am

Thanks for the follow-up.
WhiteRider
Moderator
 
Posts: 54018
Joined: Sat Jan 19, 2008 7:06 pm
Location: UK


Return to PostgreSQL [Read Only]

Who is online

Users browsing this forum: No registered users and 18 guests

cron
highfalutin