Move entire site to different slave

Discussion in 'ISPConfig 3 Priority Support' started by gbe, Aug 14, 2015.

  1. gbe

    gbe New Member HowtoForge Supporter

    Hi all,
    I've been searching for a simple way to replicate (move or copy, but preferably move) a whole website, with all associated settings and data, to a different slave server.
    By "whole site" I mean a live running site, including:
    1. site settings, including any SSL settings, redirects, statistics and options
    2. all files and folders, retaining permissions
    3. any subdomains and aliasdomains
    4. databases and their users
    5. protected folders and their users
    6. FTP accounts
    7. shell accounts and cron jobs
    If there's no way to do this through the interface, I'm hoping to learn how to do it through the API, so that I can create a script or plugin that will do it. Quite happy to release this to the community if there is any interest.
    Alternatively, a second option would be a way to backup all the above in a form that could be subsequently restored on a different slave server.
    Many thanks
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    That's not possible trough the ispconfig interface yet. The key to build such a function is the sys_datalog table, it contains the configuration transactions for all servers and the slaves pick up the config tasks from this table from the master.

    To transfer a site from server 1 to server 2 you would have to do these steps:

    1) inject a transaction into the datalog to create the site on server 2 and wait 60 seconds until it is created.
    2) copy over the data (e.g. html files, images etc. from server 1 to server 2.).
    3) change the server_id of the record in the ispconfig database from 1 to 2.
    4) inject a transaction in the datalog to delete the website on server 1.

    This procedure has to be done in a similar way for the database, the ftp users, the shell users (just that shell and ftp users dont have data that has to be copied).
    gbe likes this.
  3. gbe

    gbe New Member HowtoForge Supporter

    @till, that is extremely useful, thank you.
    I see the data field is a serialized array... I should be able to pick up everything I need by mining my copy on the master.
    I just have 2 questions:
    1. will there be issues with duplicates? eg: if I inject a record to create, targeting server2, while it still exists on server1?
    2. do you think I should I be building my code "within" ISPConfig (as some sort of add-on/plugin/module) or should I do this as an entirely external process?
      • If "within": is an Interface Module the way to go? Do you have any links to coding resources on the framework?
      • If external: does the API provide sufficient functionality for this, or am I better off talking directly to the database?
    Many thanks
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    1) No, thats no problem as server2 reads its instructions from datalog only, so this server can not know that server 1 has a website with the same domain name. A problem would only arise when you try to have a domain twice on the same server.
    2) Internal would be better as you have to deal directly with the database, the api cant do that as this magic that you have to do in the datalog is afainst the "a domain can only exist once" rule so the api wuld reject such a request like the interface is doing it. A module is probably a bit too much. I would implement this as a "tool", see e.g. the code of the resync tool in the tools module.
    gbe likes this.
  5. gbe

    gbe New Member HowtoForge Supporter

    Thanks @till, I will check out Resync tool.

Share This Page