Re: [OT] Database synchronisation



Alvaro G. Vicario wrote:

I have a database called LOCAL_DB in a local computer. This DB is managed
by third party software so I have no control over it. I have another
database called INET_DB in an Internet server. I design and maintain this
one (it's an extranet written in PHP).


There's a thing on phpclassess which claims to replicate MySQL schemas (you
didn't say what DBMS) but it doesn't understand about indices and doesn't
replicate data.

I need to write an app that dumps certain fields and tables from LOCAL_DB
into INET_DB every night, using a DSL connection, so all changes made in
the office during workday are available at the extranet the following day.
Both DBMS are different so I’m accessing data through ODBC drivers.

The first simple bold algorithm I can think of is:

1) Empty INET_DB
2) Get records from LOCAL_DB
3) For each record : Insert record into INET_DB


Assuming we're talking MySQL and you are just publishing the data, then the
bestway to do it would be to slave the remote DB from the local - but that
asssumes you can reconfigure the remote DB and connect across the MySQL
port.

An alternative approach would be to run rsync - which is supposed to just
update the bits of a large file which have changed. But you'd need to to
shutdown the DBMS while it ran.

Failing that why not just shutdown the DBMS and transfer the files across -
it'll probably be a lot quicker than rebuilding the table one row at a
time.

The best solution though would be a custom script which copies over any
changes however you need to make sure that:

1) you never delete data (well you can - you just mark it as inactive then
run a housekeeping job to delete things which have been inactive for, say 2
successful update cycles).

2) you need a timestamp and primary key field on every table.

(BTW - why bother to check if a record exists before you try and insert it -
if its already there and you've got a primary key, the DBM<S will tell you
at the time of insertion).

HTH

C.

.



Relevant Pages

  • Re: to backup mysql,what file should I copy?
    ... I do not know about mysql, but I do know about other dbms's. ... use the backup tools _in the dbms_ to backup a dbms. ... or ext3 file system stuff), the maximum size might be larger because it ...
    (comp.os.linux.misc)
  • Re: Access als Frontend für verschiedene DBMS testen
    ... >> Diese DBMS habe ich mir angesehen: JET, MSSQL, PostgreSQL 8.0, MySQL ... Datentypen im FE erkannt? ... Warum ich PostgreSQL vor MySQL stellte: ...
    (microsoft.public.de.access)
  • Re: Filesystem for Linux.
    ... MySQL was chosen as an example of a freely available DBMS. ... Filesystems store things in small blocks, say, 4K. ... Using a database would dramatically improve the speed of SEARCHING for ...
    (comp.os.linux.development.system)
  • Re: Should I use LISP for this?
    ... Check out MySQL. ... MySQL is actually a pretty bad example of an SQL DBMS. ... There are a number of other open-source SQL DBMSes, ... PostgreSQL is the best-known, and CL-SQL ...
    (comp.lang.lisp)
  • Re: Separate PK in Jxn Tbl?
    ... Tony is a very experienced Access developer; readers of Comp Databases Ms- ... Having an auto-number primary key in each table ... I happen to work with real DBMS products. ...
    (comp.databases.ms-access)