Automatic resync in crontab – is it possible?

Discussion in 'General' started by V4xen, Jan 23, 2020.

  1. V4xen

    V4xen New Member


    I have been an ispConfig user and admin for several years. However, for the first time I'm encountering a problem that I can't overcome on my own, which I'll describe below.

    I need a mechanism that will automatically run Resync (in Tools tab) from cron. The situation is that I have web.domain.tld server with ispConfig on which all services (web, db, mail etc) work. I want to create its "backup", which is a second server to mirror the former - say bck.domain.tld. So I need a continuous web->bck replication.

    I tried to create a multiserver instance with a new server (because web.domain.tld has been running for a long time and its migration is a huge workload - lots of images), but it didn't work.

    My second idea is to replicate the database (simple Master->Slave replication) as it is, i.e. full copy, including dbispconfig and mysql database, then doing Resync in cron, and then synchronizing files (also in cron). All of this would probably be one script written to crontab run every e.g. 15 minutes. Is such a solution possible at all? Is it possible to call resync via remote API or manually via /tools/resync.php?

    If not, I'll probably ask for help with retrieving the bck.domain.tld server as a multiserver mirror...

    Thanks in advance, I'm counting on your help, because I've run out of ideas.
  2. Jesse Norell

    Jesse Norell Well-Known Member Staff Member Howtoforge Staff

    In brief searching I don't find that exactly (though it might be found yet?); "use the remote api" is a common answer for many use cases. You could of course dig into the code of what happens when calling that and likely write a script that includes the relevant libraries and makes the appropriate call. Alternately, look at emulating the HTTP request which fires off such a call.

    Unless I misunderstand what you're doing, that sounds like exactly what a mirrored server does. Ie. add a second web server into your multiserver install, enable the same services on it, and set it to be a mirror of the first server. Every record/change written to the first server will also be made to the second, so there is no need to resync, they just stay in sync by design.

    That again sounds like a cumbersome way to effect a mirrored server.

    That's probably the route to go? ISPConfig sync's the db and writes out config files .. you have to arrange a sync of your data (website files, mail, databases) outside of ISPConfig itself, and there are a number of ways/technologies to do that.
    V4xen likes this.
  3. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

    If you mean ISPConfig resync tool, it will only work via GUI and not via terminal.

    However, if you still need to use it via terminal and via cron, try reading this:

    In most cases, I think official migration tool should work just fine and official support for it is also available.

    Do keep a proper backup beforehand whatever you choose to do, just in case.
    V4xen likes this.
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Setup a multiserver mirror like @Jesse Norell suggested. Tools > Resync needs to be run just once manually after you added the new slave system, further changes get synced automatically due to mirror mode.
    V4xen likes this.
  5. V4xen

    V4xen New Member

    Thank you all very much for your quick answers :)

    To quickly explain my approach: I decided to run Resync tool (yes, I mean ispConfig resync tool) from cron because of a problem with running a mirror server to an existing multiserver (I have one web server that is already working and has a lot of data, and I want to add a new server as backup). After installing a pure ispConfig as a multiserver on bck.domain.tld and changing the option on web.domain.tld to make the bck server a mirror, the sys_datalog (red circle at the top of the ispConfig GUI) on web.domain.tld will not disappear. I don't really know how to explain it... The point is that the process of changing configuration on the web server to make bck a mirror lasts forever.

    I tried to install bck from scratch several times, but it didn't work. I don't know if this could be related to the fact that on both of these servers a web (master) -> bck (slave) replication of databases (all, including dbispconfig and mysql databases) is already running. For the installation, of course, I had to make a drop of the dbispconfig database on the slave, but it did not give any results.

    Maybe one of you is able to tell me the next direction? From your answers, I conclude that running resync cron is out of the question. At this point, the whole bck works by replicating the database through the mysql mechanism. Files are synchronized with the script running in cron (in case of web server failure, moving traffic to bck will not be a problem, I will just have to manually click resync in GUI).

    So: what am I doing wrong that connecting bck server as mirror to the web fails and the sys_directory action queue hangs on the web?

    Again, thank you in advance for any help :)
  6. ahrasis

    ahrasis Well-Known Member HowtoForge Supporter

  7. V4xen

    V4xen New Member

  8. till

    till Super Moderator Staff Member ISPConfig Developer

    That's mostly caused by wrong /etc/hosts file settings, in any case, something that's easy to fix.
    V4xen likes this.
  9. V4xen

    V4xen New Member

    Well, I'll check this. Thank you all for help :cool:

Share This Page