473,809 Members | 2,736 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Duplicating a database

I need to have an exact copy of a postgres install on a testing
computer. I don't want to do slony. Is it feasible/reasonable to think
that I could just rsync to the devel boxen from the pg server? Or is
slony "The Way to Do It"(tm)?

\<.
---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddres sHere" to ma*******@postg resql.org)

Nov 23 '05 #1
4 2040
On Thu, Oct 21, 2004 at 01:39:26 -0700,
Karim Nassar <Ka**********@N AU.EDU> wrote:
I need to have an exact copy of a postgres install on a testing
computer. I don't want to do slony. Is it feasible/reasonable to think
that I could just rsync to the devel boxen from the pg server? Or is
slony "The Way to Do It"(tm)?


If you shutdown the database cluster before doing the rsync that will work.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #2
On Thu, 2004-10-21 at 02:39, Karim Nassar wrote:
I need to have an exact copy of a postgres install on a testing
computer. I don't want to do slony. Is it feasible/reasonable to think
that I could just rsync to the devel boxen from the pg server? Or is
slony "The Way to Do It"(tm)?


If you just need a working copy, not necessarily right up to date at any
time, you can just dump and restore it:

pg_dumpall -h source_server |psql -h dest_server

add switches as necessary.
---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #3
On Sat, 2004-10-23 at 22:22, Karim Nassar wrote:
If you just need a working copy, not necessarily right up to date at any
time, you can just dump and restore it:

pg_dumpall -h source_server |psql -h dest_server

add switches as necessary.


That would be great for the first time. But what I want to do is copy
~postgresql/data, stomping/deleting as necessary. Roughly, my thinking
is a daily cron job on the server:

rm -rf /safe/dir/data
/etc/init.d/postgresql stop
tar czf - -C ~postgres data | tar xzf - -C /safe/dir/
/etc/init.d/postgresql start
And a client script:

/etc/init.d/postgresql stop
rm -rf ~postgres/data
ssh user@server tar czf - -C /safe/dir data|tar xvzf - -C ~postgres
/etc/init.d/postgresql start

Or something similar with rsync instead of tar.


Assuming there's only one or two databases in the cluster, it would be
pretty easy to just do a

dropdb -h dest dbname1
dropdb -h dest dbname2
createdb dbname1
createdb dbname2
pg_dump -h source dbname1|psql -h dest
pg_dump -h source dbname2|psql -h dest

That way there's no need to take down the source server or do anything
special to it.

---------------------------(end of broadcast)---------------------------
TIP 5: Have you checked our extensive FAQ?

http://www.postgresql.org/docs/faqs/FAQ.html

Nov 23 '05 #4
If you just need a working copy, not necessarily right up to date at any
time, you can just dump and restore it:

pg_dumpall -h source_server |psql -h dest_server

add switches as necessary.
That would be great for the first time. But what I want to do is copy
~postgresql/data, stomping/deleting as necessary. Roughly, my thinking
is a daily cron job on the server:

rm -rf /safe/dir/data
/etc/init.d/postgresql stop
tar czf - -C ~postgres data | tar xzf - -C /safe/dir/
/etc/init.d/postgresql start
And a client script:

/etc/init.d/postgresql stop
rm -rf ~postgres/data
ssh user@server tar czf - -C /safe/dir data|tar xvzf - -C ~postgres
/etc/init.d/postgresql start

Or something similar with rsync instead of tar.

\<.

On Sat, 2004-10-23 at 18:04, Scott Marlowe wrote: On Thu, 2004-10-21 at 02:39, Karim Nassar wrote:
I need to have an exact copy of a postgres install on a testing
computer. I don't want to do slony. Is it feasible/reasonable to think
that I could just rsync to the devel boxen from the pg server? Or is
slony "The Way to Do It"(tm)?


If you just need a working copy, not necessarily right up to date at any
time, you can just dump and restore it:

pg_dumpall -h source_server |psql -h dest_server

add switches as necessary.

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

Nov 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
1819
by: chris | last post by:
how would i duplicate a database content into another database i have ssh access and want to do this without downloading the database and uploading it again thanks
5
12822
by: DB_2 | last post by:
I was wondering if there was a way to create a copy of a table in a single SQL statement, together with its column structure and data. In Oracle, there is a "CREATE TABLE new-table AS select-statement" that I can use to accomplish this. Is there a similar statement in DB2? I found a similar syntax structure under materialized query tables, but it appeared that the new table would remain tied to the original source in some way. Perhaps...
7
2107
by: Paolo | last post by:
I know I should not be doing this, but I find it very useful. I have a database in Access which stores data for a small company. Sometimes we need to add similar information to different tables. Currently I am already doing something similar by copying certain records into the same table. The only thing that changes is one field. Please look at the code: Dim MyDb As DAO.Database, MyRs As DAO.Recordset Dim strCode As String
6
2510
by: Robin S. | last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope I've done a better job of explaining myself below. I am trying to produce a form to add products to a table (new products). Tables: tblCategoryDetails CategoryID SpecID
2
1110
by: Todd Plambeck | last post by:
I have an ASP.net order entry system that will occasionally insert duplcate orders into the database. We are using SQL Server for the session state. This also only seems to happen when the server has not been rebooted for a long period of time. When it starts duplicating, it will do so about 3 or 4 times and it's not every order. Some will come in fine the next one gets duped, the next couple are fine, then another dupe or two, etc. ...
3
1068
by: RSH | last post by:
I have a situation where I have almost 100 databases that when we get a new client we need to 'copy' the template databases and rename them and I would like to be able to write a VB .Net application to quickly make copies of the databases and then transfer the data to the new databases. I have the data transfer script written, i just need some way of copying the databases one at a time with all of the table structures and renaming the...
0
1069
by: rmli | last post by:
Duplicating a Database using RMAN http://quickdba.blogspot.com/2006/05/duplicating-database-using-rman_22.html
5
1206
by: JohnC | last post by:
I have a webapp that allows users to delete/add content on a webpage. The webpage is accessed like this: www.abc.com/app/user1/ www.abc.com/app/user2/ where index.aspx is the default page. To do the above though requires creating a new user subfolder, copying the index.aspx page from the app folder and renaming it. This can be problematic when I need to update templates.
0
928
by: Jonathan Wood | last post by:
When a GridView performs a row edit, edit controls appear without needing to display a different page, or, apparently, needing to refresh the existing page. Does anyone have tips on duplicating this functionality. I'm guessing it involves a bunch of javascript, which my abilities are limited with. I need to edit some data that will exist in an array and not directly in a database. I know I can use an array as the GridView's datasource,...
0
9721
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10635
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10115
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9198
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7653
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6881
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5550
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4332
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.