How to synchronise a file to 2 different hosts?

Hello,

We ve got 2 sites (Site1, Site2), joined thanks vpn.
We had 2 differents files with a list of all host in each sites.
Server1 has list1.ini, and Server2 has list2.ini

everyone from Site1 update list1.ini by ssh or script to Server1
everyone from Site2 update list2.ini by ssh or script to Server2

Actually, we wants to have only one file, but users from Site1 still wants to update list1.ini
and users from Site2 still wants to update list2.ini

Maybe later, they will be Ok to reach another uniq file, but for now it's like that ...

Is there a command to synchronize list1.ini and list2.ini up to date everytime someone modify it ?

I think, it can be easy to upgrade scripts, but some users still modify this file by hand (the time our uniq file is validate), cause it's THEIR file !! Nevermind ...

At the begining i thought to make some diff/rsync ... but the problem is, it will not be able to update for a host deleted from the list, it can only see adds ?

I hope i was clear, english is not my natal langage ... i just want to synchronise a file up to date to 2 differents host whatever we add or delete something from the list file.

Thanks

Do you have a backup server or some other host that you could do this forced sync/copy from?

You can cat the two files (from each site) together and sort for uniqueness and push out to both sites.

That's the "easy" way, but assumes that list can be sorted... ok?

If you don't have a 3rd server, then each server does:

site1:

ssh site2 cat list2.ini >/tmp/list.ini
cat list1.ini >>/tmp/list.ini
sort -u -o /tmp/list.ini /tmp/list.ini
cp /tmp/list.ini list1.ini

site2:

ssh site1 cat list1.ini >/tmp/list.ini
cat list2.ini >>/tmp/list.ini
sort -u -o /tmp/list.ini /tmp/list.ini
cp /tmp/list.ini list2.ini

That's very rough, no error checking at all.