Webmin > ISPconfig

Discussion in 'Installation/Configuration' started by kresimir, Dec 8, 2020.

  1. kresimir

    kresimir New Member

    Hi all,

    I've client domains that I host on my old server that is under webmin. I've setup new server and I installed ISPconfig latest version. What I can do is prepare all files & database dumps from old server and copy it to new but I don't know where should I copy them (and DB dumps) and what commands should I execute after (I guess that I can call some functions like webmin has bash commands for ex. `virtualmin add-web --domain domain.xyz`)
    I hope that I don't have to manually click and create each site from web admin..and then use bash to transfer DB/files?
    I have bought PDF manual but AFAIK I haven't found example that I need.. any help in that direction is appreciated!
  2. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Probably use the ui if it's not very many sites to setup. You can script that type of thing, but it takes some work to get setup, though definitely an option if you have lots of domains.

    The specific commands to use to put your data in place with be quite dependant on what format it is in. It will probably include mysql as well as tar or zip, and general shell commands. Maybe someone familiar with webmin could have some experience to share, but otherwise just start working towards copying one site and post back if you have specific questions/issues.
  3. kresimir

    kresimir New Member

    Hi Jesse,

    I know how to script, that is not problem and format is no issue - I can prepare data how ever is needed (that is only format nothing more) but my question is - is there any set of shell commands that I can trigger to automate some of the UI tasks for example - most common ones as I see out of my head:
    - create new customer (get ID back for linking with site latter)
    - create new website (get ID of the site so latter I can map it)
    - create new DB / DB user / DB pass (to be able to import old DB dumps and `sed` / modify connection strings in config files)

    I created this script when I prepare tar.gz from Virtualmin to restore to ISPconfig but I need to have already created sites before..

    # restore script for all sites from virtualmin > ispconfig thing:
    #     /home/BACK > /var/www
    # tar.gz files exported file via virtualmin and transported in local dir
    # SET TO INCLUDE DOT FILES (/directories)
    shopt -s dotglob
    cd /home/BACK
    for i in **; do  # echo $i > domain.xyz
        echo "Looping ... $i"
        # make domain name dir & move & extract tar
        if [ -d "/var/www/$i" ] && [ -f "/var/www/$i/web/wp-config.php" ]; then
            echo " - Entering ... $i"
            # get user/group from
            UN=$(stat -c '%U' "/var/www/$i/web")
            GR=$(stat -c '%G' "/var/www/$i/web")
            # copy backup www root from ARCHIVE to WEB ROOT
            cp "/var/www/$i/web/wp-config.php" /home/BACK/$i/public_html # COPY CONFIG FILE
            rm -rf /var/www/$i/web/* # CLEAN WWW ROOT
            mv /home/BACK/$i/public_html/* /var/www/$i/web/ # COPY BCK TO ROOT
            chown -R $UN:$GR /var/www/$i/web # SET PERMS
            # MYSQL
            DBU=`cat /var/www/$i/web/wp-config.php | grep DB_USER | cut -d \' -f 4`
            DBP=`cat /var/www/$i/web/wp-config.php | grep DB_PASSWORD | cut -d \' -f 4`
            DBD=`cat /var/www/$i/web/wp-config.php | grep DB_NAME | cut -d \' -f 4`
            # mysql pass env & import
            export MYSQL_PWD=$DBP
            FL=$(ls /var/www/$i/web/.backup/*_mysql_*)
            mysql -u $DBU $DBD < $FL
            [ ! -d "/home/BACK/.Done" ] && mkdir "/home/BACK/.Done"
            mv "/home/BACK/$i" "/home/BACK/.Done"
            echo " - mysql - $FL"
            echo " - Done host - $i"
    but if I could script couple of steps that are outlined in bullets before - that would be more awesome ..
    I don't have email accounts so that is something that I don't need to manage at all.. thanks for any help
  4. nhybgtvfr

    nhybgtvfr Well-Known Member HowtoForge Supporter

    there's a wizard for creating a site/dns/ftp/db/mail etc.
    Projects · ISPConfig / module-wizard · GitLab
    you should be able to get most of the code you want from that.

    not sure if it'll tell you the id's it creates. but you could use it as a base for your own scripts to automate all the config creation.
    getting all the id's afterwards is just a few db queries.
    i don't believe the migration tool does anything with webmin.
    otherwise, it's a case of downloading the ispconfig install tarball, and looking at the api examples in that and going from there...
  5. Jesse Norell

    Jesse Norell ISPConfig Developer Staff Member ISPConfig Developer

    Someone started a bash client for the api once, I don't know how complete it became. You could find it and numerous php api clients in the forums, in addition to the examples in the installation sources.

Share This Page