Re: copy database from one server to another

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Copy database from one server to another server:

I have described it at
http://bimal.org.np/?d=php_tutorials&p=synchronize_database
Be sure to check for the updates, or ask me for the soruce code 
in personal. There is some reason not publishing the source.


-----------[ message from my website]----------------

This case is very normal, as I experienced. I had to duplicate the
entire database, once. But the server did not allowed to copy/paster
the MySQL's base-data files. So, I had to know the newly appearing
columns after I took the dump last time, because I should not consider
the data that I took already.

Here was a simple case:
In the main server, I was not allwed to connect remotely.
In my test server, I could do it, and opened an account of MySQL, so
that I could connect using SSH. Both the server's allowed SSH. I maded
one apllication which uploaded the newly appearing database entries to
my test server. I then installed it into a cron-job in the main
server. So, I was getting the new entries in the test server as well.
The test server was used for different purpose than the regular
in-production server. Here is the application logic, all done in PHP.

1. Duplicate the real data int test server, by taking a database dump,
and restoring in the other server. Now onwards each time, for each
tables do this:
2. Know the maximum ID, primary key of the test (or
earlier-duplicated) table. Then, make an SQL for each rows whose id is
greater than the just calculated ID, in the main server, build the
INSERT INTO statements.
3. Run the INSERT INTO statements into the test server from the Cron
running in the main database server.
4. Thus, after the Cron ran in the main server, I always got a fresh
entires in the test server. So, there was a PERFCECT synchronisation
under limited resources.

What if both of the servers do not allow you to connect remotely?
1. Simple. Write the SQL (INSERT INTO) into a file in the server.
2. Download it in your computer.
3. Upload it in the new/test server.
4. Run the SQL there in.

How do you find this idea?
If you had readout my earlier article amout MySQL database and
connection classes, it might be useful to learn you how to solve this
case. However, all are describled. But because of the time constraint
I am not being able to clear my login details from the source code, I
am not publising it now. If you think, you should get it, please write
me an email.


[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux