PHP / MySQL Synchronization Conceptual Database

I am working on a PHP class that implements PDO to synchronize a local database table with a remote one.

Question

I am looking for some ideas / methods / suggestions on how to implement the “backup” function for my synchronization process. The ideas is : before actually inserting the data, the data of the local tables is completely cleared. Time is not a factor, so I believe that this is the simplest and easiest solution, and I will not worry about checking the differences in data and all this jazz. The Problem is , I want to implement some kind of security measure in case of a problem during data insertion, for example, loss of Internet connection or something like that. The only idea I have so far: Copy the specified table for synchronization → delete the specified table → paste the data of the deleted tables into the local table → if you can delete the backup.

+4
source share
2 answers

Check out the mk-table-sync . It compares two tables on different servers using checksums of pieces of rows. If this block is identical between two servers, copying is not required. If a piece is different, it copies only the piece that it needs. You do not need to erase the local table.

Another alternative is to copy the deleted data to a separate table name. If it succeeds, then DROP the old table and RENAME the new local copy in the original table name. If the copy fails or is interrupted, open a local copy with a different name and try again. Meanwhile, your other local table with previous data is not affected.

+3
source

Below is a web-based tool that synchronizes the database between you and the server or another developer.

This is Git Based. Therefore, you should use Git in the project.

But this is only useful when developing an application. it is not a tool for comparing databases.

For synchronization databases, you regularly push the code on Git.

Git Project: https://github.com/hardeepvicky/DB-Sync

0
source

All Articles