eRegistrations Benin · handover

Server requirementsV4 transfer (FR)

Rebuild the S4 archive on the new server: 722 GB to move, in 24 steps

Do not try to migrate the hosting control panel. Build a clean Ubuntu 24.04 machine, copy a named list of data onto it, and switch the web address over. Almost all of the 722 GB is the document store, and copying it is the only long part. Everything else takes a few hours.

Where you are starting from

This plan was written from a read-only inspection of the source server. Nothing on it was changed. It is written for a system administrator who has never seen the machine.

Source

Server
archive.monentreprise.bj
Operating system
Ubuntu 18.04.6
Hosting
Plesk Obsidian 18.0.80.7
Database
MariaDB 10.5.9

Target

Operating system
Ubuntu Server 24.04 LTS
Web server
nginx talking straight to PHP-FPM. No Apache, no control panel.
Application
Yii 1, version 3.2.0, running on PHP 7.4
Scope
The production archive only, unless section 11 applies.

The source system disk has little free space. Do not write anything to it during this work. If you need scratch space on the source, use /mnt/volume-bj, which has 208 GB free. Run every copy from the new machine, pulling, so that nothing large is ever created on the source.

1 · What you are moving

Seven items. Everything not on this list stays behind.

ItemPath on the sourceSize
Production databaseThe one live database MariaDB schema ereg_benin_prod 17 GB loaded13 GB as SQL, 1.2 GB compressed
Applicant documentsThe bulk of the transfer /mnt/volume-bj/monentreprise.bj/documents 524 GB267 293 top-level folders
Issued certificatesGenerated PDFs and images /mnt/volume-bj/monentreprise.bj/certificats 195 GB236 422 top-level folders
Application codeYii 1 application, version 3.2.0 /var/www/vhosts/benin.eregistrations.org/httpdocs about 2.8 GBafter exclusions; 21 GB raw
Application configurationSee step 17 and step 18 httpdocs/protected/config/ under 100 KB
TLS certificateOr simply re-issue on the new machine, which is what step 23 does Control panel store a few KB
Nightly backup jobRe-create it, with a new password root crontab 1 line

Transfer total: about 722 GB. The two file stores are 718 GB of that, spread over 7.07 million files.

2 · How long the file copy takes

For the 718 GB file store, using rsync with 8 parallel streams.

Link speedByte timeRealistic time with 7 million files
100 Mbit/sabout 16 h20–24 h
500 Mbit/sabout 3.5 h6–8 h
1 Gbit/sabout 1.7 h4–6 h

The file count, not the bandwidth, sets the floor. Plan for a first full copy that runs overnight, and a second, short, catch-up pass just before the cut-over.

3 · To confirm before you start

Do not begin until every line here has an answer. Each one can stop the work halfway.

  1. Confirm access to the source server.

    The new machine must be able to reach the source server over SSH. Arrange that with whoever administers it.

  2. Decide the scope.

    This plan moves the production archive only: the site served at archive.monentreprise.bj, its database ereg_benin_prod, and its document store. Confirm whether the test site, the dev site, the chat server and the statistics containers must move too. If they must, add the items in section 11.

  3. Confirm the target disk.

    You need at least 800 GB for the document store on its own file system, plus 60 GB on the system disk for the application, the database and room to restore. The database needs 17 GB once loaded, and the plain-text dump is 13 GB.

  4. Confirm PHP 7.4 is acceptable.

    The application runs on PHP 7.4.33 and will not run on PHP 8. PHP 7.4 is past end of life and is not in Ubuntu 24.04. You must either add a third-party PHP 7.4 package source, or run PHP 7.4 inside a container. Third-party packages for PHP 7.4 on Ubuntu 24.04 do exist and are rebuilt regularly, but no free source issues security fixes for PHP 7.4 itself; paid support for it is sold separately. Check which route your security policy allows before you build anything.

  5. Confirm the PDF generator works on the new operating system.

    The application generates every certificate with wkhtmltopdf 0.12.5 (with patched qt), installed as a static binary in /usr/local/bin and built for a much older Ubuntu. Test it early, in step 6. If it will not run, plan to run it in a container.

  6. Confirm network reach to the internal services.

    The application calls an internal business registry backend over XML-RPC. It must be reachable from the new machine. Ask the network team to confirm that, and to confirm which client networks must reach the new machine. The source server allows web traffic from one Benin network range.

  7. Confirm outbound mail.

    The application sends all its mail through a hosted SMTP relay on port 587. Confirm that the new machine may open outbound port 587, and confirm who holds the relay credentials.

  8. Rotate three credentials.

    The database password for the nightly backup is stored in plain text in root’s crontab and in the control panel’s task table. The SMTP relay credentials sit in plain text in the application’s .env. Change all of them as part of this move. Do not carry the old values forward.

  9. Confirm the DNS plan.

    DNS for these domains is served by an external provider, not by the source server, so the cut-over is a record change at the provider. Confirm who can make it, and how long the current TTL is.

  10. Confirm siggufe_db is no longer in use.

    This small database on the source has had no writes since the database server last started. The plan treats it as historical and copies it once, read-only. Ask the application owner whether anything still reads it.

  11. Protect the source disk.

    The source system disk has little free space. Do not write anything to it during this work. Use /mnt/volume-bj for scratch space; it has 208 GB free.

4 · Files that are not part of the application

These are not part of the application and must not be carried over. Be exact about them: the exclusions in steps 10 to 12 depend on this list.

Not part of this application — do not copy

  • /var/www/vhosts/eregistrations.org/
  • The databases ereg_benin and ereg_yii2. Despite their names, they do not belong to this application. Leave them.
  • /var/qmail/mailnames/ folders for any domain other than archive.monentreprise.bj and test.benin.eregistrations.org.
  • The BIND zone files on the source. They are unused leftovers; public DNS is served elsewhere.

Old backups and dumps — 64 GB

  • /var/www/vhosts/benin.eregistrations.org/_backup_prod — 51 GB, 30 nightly dumps. You only need one fresh dump, which you take in step 8.
  • httpdocs/_backup — 13 GB, two recent dumps.
  • Old .sql.zip dumps of the dev, test and migration databases, in the home folder — 176 MB.

Cache, logs and generated files — recreate them empty

  • httpdocs/protected/runtime — 5.2 GB of application logs, old migration logs and export scratch. Create the folder empty and writable; the application refills it.
  • httpdocs/assets — 469 MB. The framework republishes these automatically on the first request.
  • /var/www/vhosts/system/*/logs — web server logs.

Stale copies of the site

  • old-benin.eregistrations.org (7.3 GB) — this domain is suspended.
  • backup_test.benin.eregistrations.org (1.5 GB), dated copies of the test site and of the statistics folders, ASIN-REQUEST-OLD (25 MB) and httpdocs/JsonDataV4_INVEST_OLD.

Developer toolchains left in the home folder — 8.5 GB

  • go (4.4 GB), homebrew (2.3 GB), git (786 MB), python (363 MB), glibc (309 MB), go-sdk (253 MB), bison-3.8.2 (55 MB), venv, .cargo, .bun, .gem, .nodenv, .composer, .cache, .config, .local.

Hidden PHP files and ad-hoc scripts — exclude by pattern, then check after copying

  • Every file matching .*.php — that is, hidden PHP files. They are not part of the application and must not be carried over.
  • httpdocs/webgrind/ — a profiler interface. Not part of the application.
  • Loose scripts and .zip archives at the top of the web root that the application does not reference. Check any file at that level against the application’s own files before you copy it.

The control panel itself. You are not installing Plesk on the new machine. Section 10 explains why.

5 · Phase 1 — Build the new machine

Steps 1 to 7. About two hours of work, plus whatever the network request takes.

  1. Install the base system and create the file systems

    Install Ubuntu Server 24.04 LTS. Give the document store its own file system.

    sudo mkdir -p /srv/ereg-files
    # mount your data disk at /srv/ereg-files via /etc/fstab, then:
    df -h /srv/ereg-files

    Produces — an empty file system of at least 800 GB at /srv/ereg-files.
    Time — 30 minutes.
    Check — df -h /srv/ereg-files shows at least 800 GB available, and df -i /srv/ereg-files shows at least 10 million free inodes. If you format with ext4, use mkfs.ext4 -T news or pass -i 8192, so that you do not run out of inodes before you run out of space.

  2. Install the web server and the database
    sudo apt update
    sudo apt install -y nginx mariadb-server
    sudo systemctl enable --now nginx mariadb
    mariadb --version

    Produces — nginx and MariaDB running.
    Time — 10 minutes.
    Check — mariadb --version prints a version. Ubuntu 24.04 ships MariaDB 10.11 or newer. That is a supported upgrade path from the source’s 10.5, and a dump-and-restore handles it. Read step 15 before you load any data: one server setting must change.

  3. Install PHP 7.4 and the extensions the application needs

    The application will not run on PHP 8. Add a PHP 7.4 package source, or use a container.

    sudo apt install -y software-properties-common
    sudo add-apt-repository -y ppa:ondrej/php
    sudo apt update
    sudo apt install -y php7.4-fpm php7.4-mysql php7.4-gd php7.4-imagick php7.4-intl \
      php7.4-mbstring php7.4-curl php7.4-soap php7.4-xml php7.4-xsl php7.4-zip \
      php7.4-bcmath php7.4-gmp php7.4-ldap php7.4-memcached php7.4-redis \
      php7.4-imap php7.4-tidy php7.4-opcache
    php7.4 -m

    Produces — PHP 7.4 with the same extension set the source uses.
    Time — 15 minutes.
    Check — php7.4 -m lists at least gd imagick intl mbstring curl soap xml xsl zip bcmath gmp ldap memcached redis imap tidy pdo_mysql mysqli sockets sodium openssl and Zend OPcache.

    The source also loads the ionCube loader. You do not need it. No application file is ionCube-encoded. The loader is left over from an old install. Skip it.

    If PHP 7.4 packages are not allowed, run the application in a container built from the php:7.4-fpm image with the same extensions, and point nginx at the container’s socket. The rest of this plan is unchanged; only the fastcgi_pass line in step 14 differs.

  4. Install the supporting services
    sudo apt install -y memcached redis-server
    sudo systemctl enable --now memcached redis-server

    Produces — the two cache services the application configuration expects.
    Time — 5 minutes.
    Check — systemctl is-active memcached redis-server prints active twice. The application uses memcached to cache the database schema. If it is missing, the site still runs, but every page re-reads the schema and is slow.

  5. Create the system user and the directory layout
    sudo useradd -r -m -d /srv/ereg -s /bin/bash ereg
    sudo mkdir -p /srv/ereg/httpdocs /srv/ereg-files/documents /srv/ereg-files/certificats
    sudo chown -R ereg:ereg /srv/ereg /srv/ereg-files

    Produces — the home for the application and the two file-store folders.
    Time — 2 minutes.
    Check — ls -ld /srv/ereg/httpdocs /srv/ereg-files/documents shows owner ereg.

  6. Install and test the PDF generator

    This is the step most likely to fail. Do it now, not at the end.

    # try the packaged build first
    sudo apt install -y wkhtmltopdf xfonts-75dpi xfonts-base fonts-dejavu-core
    wkhtmltopdf --version
    echo '<h1>test</h1>' > /tmp/t.html && wkhtmltopdf /tmp/t.html /tmp/t.pdf && ls -l /tmp/t.pdf

    Produces — a working wkhtmltopdf, and a one-page test PDF.
    Time — 15 minutes, or up to an hour if you need the container fallback.
    Check — wkhtmltopdf --version must say “with patched qt”. A build without patched Qt cannot render page headers and footers, and the certificates come out wrong. If the packaged version is not patched, do not go looking for an official build for this version of Ubuntu — the project is no longer maintained and publishes none. Run wkhtmltopdf inside a small container built on an older base instead, and call it through a wrapper script at /usr/local/bin/wkhtmltopdf.

    The source also carries four custom fonts used by the certificate templates. Copy them in step 12, then install them:

    sudo cp /srv/ereg/httpdocs/wkfonts/*.ttf /usr/local/share/fonts/ && sudo fc-cache -f
  7. Open the network path for the transfer

    Allow SSH from the new machine to the source server. Ask whoever administers the source server to allow the new machine’s address, inbound and outbound.

    Produces — a working SSH path between the two machines.
    Time — depends on whoever administers the source server.
    Check — from the new machine, ssh <user>@archive.monentreprise.bj 'hostname' returns the source hostname. If this fails, stop. Everything below needs it.

6 · Phase 2 — Copy the data

Steps 8 to 13. This is the long phase. Run every copy from the new machine, pulling. Never create a large file on the source.

  1. Take a fresh database dump on the source, onto the data volume
    ssh <user>@archive.monentreprise.bj \
     "sudo mysqldump --single-transaction --quick --user=<DB_USER> -p \
        --default-character-set=utf8 ereg_benin_prod | bzip2 > /mnt/volume-bj/ereg_prod_move.sql.bz2"

    Produces — a compressed dump of about 1.2 GB at /mnt/volume-bj/ereg_prod_move.sql.bz2.
    Time — 25 to 40 minutes.
    Check — ls -l on the file shows roughly 1.1 to 1.3 GB, and bzip2 -t /mnt/volume-bj/ereg_prod_move.sql.bz2 exits without error.

    Why on /mnt/volume-bj — it has 208 GB free. The system disk does not have room.
    Why --default-character-set=utf8 — the application connects with charset => utf8, not utf8mb4. Dumping and restoring with the same character set keeps accented French text correct.

  2. Pull the database dump
    rsync -a --info=progress2 \
      <user>@archive.monentreprise.bj:/mnt/volume-bj/ereg_prod_move.sql.bz2 /srv/ereg/

    Produces — the dump on the new machine.
    Time — 2 to 20 minutes, depending on the link.
    Check — bzip2 -t /srv/ereg/ereg_prod_move.sql.bz2 exits 0.

  3. Pull the certificates store — 195 GB

    Split it into parallel streams. A single rsync over 236 000 folders is slow.

    cd /srv/ereg-files
    for i in 0 1 2 3 4 5 6 7 8 9; do
      rsync -a --numeric-ids --no-owner --no-group --info=progress2 \
        --exclude='.*.php' \
        --include="$i" --include="$i*/" --include="$i*/**" --exclude='*' \
        <user>@archive.monentreprise.bj:/mnt/volume-bj/monentreprise.bj/certificats/ certificats/ &
    done
    wait

    Produces — /srv/ereg-files/certificats holding about 195 GB.
    Time — 2 to 8 hours.
    Check — du -sh /srv/ereg-files/certificats reads about 195 GB, and the folder count matches:

    ls /srv/ereg-files/certificats | wc -l     # expect 236422

    Note the --exclude='.*.php' — it excludes hidden PHP files, which are not part of the application. Keep it.

  4. Pull the documents store — about 524 GB

    Same method, same exclusion.

    cd /srv/ereg-files
    for i in 0 1 2 3 4 5 6 7 8 9; do
      rsync -a --numeric-ids --no-owner --no-group --info=progress2 \
        --exclude='.*.php' \
        --include="$i" --include="$i*/" --include="$i*/**" --exclude='*' \
        <user>@archive.monentreprise.bj:/mnt/volume-bj/monentreprise.bj/documents/ documents/ &
    done
    wait

    Produces — /srv/ereg-files/documents holding about 524 GB.
    Time — 4 to 20 hours. This is the longest step. Run it overnight.
    Check —

    ls /srv/ereg-files/documents | wc -l       # expect 267293
    du -sh /srv/ereg-files/documents           # expect about 524G
    find /srv/ereg-files -name '.*.php'        # must print nothing

    If the last command prints anything, delete those files before going further.

  5. Pull the application code
    rsync -a --numeric-ids --no-owner --no-group --info=progress2 \
      --exclude='_backup/' \
      --exclude='protected/runtime/' \
      --exclude='assets/' \
      --exclude='.*.php' \
      --exclude='webgrind/' \
      --exclude='*.zip' \
      --exclude='documents' --exclude='certificats' \
      <user>@archive.monentreprise.bj:/var/www/vhosts/benin.eregistrations.org/httpdocs/ \
      /srv/ereg/httpdocs/

    Produces — about 2.8 GB of application code at /srv/ereg/httpdocs.
    Time — 10 to 30 minutes.
    Check —

    du -sh /srv/ereg/httpdocs                          # about 2.8G, not 21G
    ls /srv/ereg/httpdocs/index.php                    # must exist
    ls /srv/ereg/httpdocs/protected/config/main.php    # must exist
    find /srv/ereg/httpdocs -name '.*.php'             # must print nothing

    documents and certificats are excluded because on the source they are symbolic links into /mnt/volume-bj. You recreate them in step 13.

  6. Recreate the runtime folders and the two symbolic links
    sudo -u ereg mkdir -p /srv/ereg/httpdocs/protected/runtime/exports \
                          /srv/ereg/httpdocs/assets \
                          /srv/ereg/httpdocs/uploads/tmp \
                          /srv/ereg/httpdocs/exports
    sudo -u ereg ln -s /srv/ereg-files/documents   /srv/ereg/httpdocs/documents
    sudo -u ereg ln -s /srv/ereg-files/certificats /srv/ereg/httpdocs/certificats
    sudo chown -R ereg:ereg /srv/ereg /srv/ereg-files
    sudo chmod -R u+rwX /srv/ereg/httpdocs/protected/runtime /srv/ereg/httpdocs/assets \
                        /srv/ereg/httpdocs/uploads /srv/ereg/httpdocs/exports

    Produces — the writable folders the application needs, and the two links it reads documents through.
    Time — 5 minutes, plus up to 30 minutes for the chown across 7 million files.
    Check — ls -l /srv/ereg/httpdocs/documents shows a link to /srv/ereg-files/documents, and writing a test file as the ereg user into protected/runtime succeeds.

7 · Phase 3 — Restore and configure

Steps 14 to 19. About three to four hours, most of it the database restore.

  1. Write the nginx site and the PHP-FPM pool

    The source runs nginx in front of Apache. You do not need Apache. nginx talking straight to PHP-FPM does the same job.

    Create /etc/nginx/sites-available/ereg:

    server {
        listen 80;
        server_name archive.monentreprise.bj;
        root /srv/ereg/httpdocs;
        index index.php;
    
        client_max_body_size 128m;          # source value: 134217728 bytes
    
        location / { try_files $uri $uri/ /index.php?$args; }
    
        location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/run/php/php7.4-fpm-ereg.sock;
            fastcgi_read_timeout 300;
        }
    
        # do not serve hidden files
        location ~ /\. { deny all; }
    }

    Create the PHP-FPM pool /etc/php/7.4/fpm/pool.d/ereg.conf with these values, which match the source pool exactly:

    [ereg]
    user = ereg
    group = ereg
    listen = /run/php/php7.4-fpm-ereg.sock
    listen.owner = www-data
    listen.group = www-data
    listen.mode = 0660
    pm = dynamic
    pm.max_children = 20
    php_value[memory_limit] = 300M
    php_value[post_max_size] = 16M
    php_value[upload_max_filesize] = 16M
    php_value[allow_url_fopen] = off
    php_value[cgi.fix_pathinfo] = 0
    php_value[expose_php] = off
    php_value[date.timezone] = Africa/Porto-Novo
    php_value[open_basedir] = "/srv/ereg/:/srv/ereg-files/:/tmp/"
    sudo ln -s /etc/nginx/sites-available/ereg /etc/nginx/sites-enabled/
    sudo nginx -t && sudo systemctl reload nginx
    sudo systemctl restart php7.4-fpm

    Produces — a served site, not yet working, because there is no database.
    Time — 20 minutes.
    Check — nginx -t says the configuration is ok, and curl -I http://localhost -H 'Host: archive.monentreprise.bj' returns a response, most likely a 500 at this point. That is expected until the database is loaded, in step 16.

    open_basedir must list the file store. If you leave the file store out, every document download fails with a permission error, and nothing in the application log explains why.

  2. Set the database server options, then create the database

    Before you load anything, set these in /etc/mysql/mariadb.conf.d/50-server.cnf:

    [mysqld]
    character-set-server = utf8mb4
    sql_mode = "ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION"
    innodb_buffer_pool_size = 8G      # size this to about 40% of the new machine's RAM
    innodb_file_per_table = 1
    max_allowed_packet = 256M
    sudo systemctl restart mariadb
    sudo mariadb -e "CREATE DATABASE ereg_benin_prod CHARACTER SET utf8mb4;"
    sudo mariadb -e "CREATE USER '<DB_USER>'@'localhost' IDENTIFIED BY '<NEW_PASSWORD>';"
    sudo mariadb -e "GRANT ALL ON ereg_benin_prod.* TO '<DB_USER>'@'localhost'; FLUSH PRIVILEGES;"

    Produces — an empty database and its user.
    Time — 10 minutes.
    Check — sudo mariadb -e "SHOW DATABASES" lists ereg_benin_prod.
    Choose a new database user and a new password on the new machine — do not reuse the ones from the source. You put them into .env in step 17.

    Two differences from the source that you must not copy. First, the source sql_mode includes NO_AUTO_CREATE_USER; that flag was removed from newer database servers and will make the server refuse to start, so leave it out, as shown above. Second, the source grants its database users from '%', meaning any host; create yours on 'localhost' only, because nothing needs remote database access.

  3. Restore the database
    cd /srv/ereg
    bunzip2 -c ereg_prod_move.sql.bz2 | sudo mariadb --default-character-set=utf8 ereg_benin_prod

    Produces — about 17 GB of data in ereg_benin_prod.
    Time — 45 to 90 minutes.
    Check —

    sudo mariadb -e "SELECT COUNT(*) FROM ereg_benin_prod.tbl_entreprise;"   # expect about 549803
    sudo mariadb -e "SELECT COUNT(*) FROM ereg_benin_prod.tbl_certificat;"   # expect about 1854126
    sudo mariadb -e "SELECT COUNT(*) FROM ereg_benin_prod.tbl_request;"      # expect about 2132410

    Compare these against the same counts taken on the source before you began. They should match, or differ only by rows added since the dump.

    You can safely empty the session table afterwards. It holds 7.7 million expired web sessions and 5.3 GB:

    sudo mariadb -e "TRUNCATE TABLE ereg_benin_prod.YiiSession;"
  4. Edit the application’s environment file

    The file is /srv/ereg/httpdocs/protected/config/.env. Change the settings below. Names only: take the values from your own new setup, never from the old file.

    SettingWhat it must become
    PHP_BINARYThe new PHP 7.4 path, for example /usr/bin/php7.4. The old value points into the control panel’s own tree.
    DOMAIN_NAMEThe hostname the site will answer on. Currently archive.monentreprise.bj.
    DATABASE_HOST, DATABASE_PORT127.0.0.1 and 3306 — unchanged, but confirm.
    DATABASE_NAMEereg_benin_prod — unchanged.
    DATABASE_USER, DATABASE_PASSWORDThe new credentials from step 15. Never reuse the old password.
    SMTP_HOST, SMTP_PORT, SMTP_ENCRYPTIONConfirm the relay still accepts them.
    SMTP_USERNAME, SMTP_PASSWORDNew, rotated relay credentials.
    SYSTEM_ADMIN_EMAILWhere application error mail goes. Currently a personal address. Change it to a team mailbox.
    WKHTMLTOPDF_BIN_PATHThe path you validated in step 6.
    ENVIRONMENTLeave as prod.
    HTTPS_ENABLEDLeave as 1 once TLS is on. It controls the secure flag on the session cookie.
    USER_SESSION_NAME, USER_SESSION_TIMEOUTLeave as they are. Changing the name logs everyone out.
    YII_DEBUGMust stay 0.

    Time — 15 minutes.
    Check — the ereg user can read the file.

  5. Check the other configuration files

    These read their values from .env, so most need no edit. Read each one and confirm.

    FileWhat to look at
    protected/config/params.phpportal_url is a hard-coded absolute address for the public site — update it. Also check adminEmail, SupportEmail, gmaps_key, currency, documents_folder, certificats_folder. Get a new Google Maps key: reissue it as part of the move and put the new value in the new machine’s configuration.
    protected/config/main.phptimeZone (Africa/Porto-Novo), name, theme, language. No paths to change; it uses relative paths.
    protected/config/prod.phpThe log routes. EmailLogRoute sends errors to SYSTEM_ADMIN_EMAIL with a hard-coded sender address — change it if the sending domain changes. The database options charset => utf8 and tablePrefix => tbl_ must not change.
    protected/config/database.phpReads .env. No edit.
    protected/config/session.phpReads .env. Sessions are stored in the database, not on disk, so there is nothing to copy.
    protected/config/smtp.phpReads .env. It substitutes the literal text [domain] with the hostname, so if SMTP_HOST contains [domain] it becomes the site hostname.
    protected/config/hoauth.phpEvery external login provider is set to enabled => false. Leave it that way. The file contains client identifiers and secrets for several third-party services. None of it is in use. Reissue them as part of the move and put the new values in the new machine’s configuration.
    protected/config/dkim_private.pemA mail-signing key. The code that used it is commented out. Do not copy it. Generate a new key if you turn DKIM on.
    protected/config/env.phpReturns the literal string prod. Leave it.
    httpdocs/.htaccessApache rules only. With nginx it is inert; the equivalent rewrite is already in the nginx configuration from step 14.

    Time — 30 minutes.
    Check — search the configuration folder for any remaining absolute path from the old machine:

    grep -rn "/var/www\|/opt/plesk\|/mnt/volume-bj" /srv/ereg/httpdocs/protected/config/

    It should print nothing.

  6. Re-create the nightly backup, with a new password

    Do not copy the old crontab line. It stores the database password in plain text, which is visible to every user on the machine through the process list. Use an option file instead.

    sudo install -m 600 /dev/null /root/.my.cnf
    # put [mysqldump] user= and password= in /root/.my.cnf, then:
    sudo crontab -e

    Add:

    0 19 * * * cd /srv/backups && D=$(date +\%Y-\%m-\%d) && mysqldump --single-transaction --quick ereg_benin_prod | bzip2 > db_$D.sql.bz2
    0 18 * * * find /srv/backups -name 'db_*.sql.bz2' -mtime +30 -delete

    Produces — a nightly 1.2 GB compressed dump, kept 30 days, so about 36 GB.
    Time — 15 minutes.
    Check — run the dump command by hand once, and confirm bzip2 -t passes on the result. Make sure /srv/backups is on a file system with at least 60 GB free, and, if you can avoid it, not on the same disk as the database.
    Also — copy the dump off the machine. The source has no off-site copy of this database at all.

8 · Phase 4 — Verify

Steps 20 to 22. About an hour, plus whatever the network team needs.

  1. Start the site and read the log
    curl -s -o /dev/null -w '%{http_code}\n' http://localhost -H 'Host: archive.monentreprise.bj'
    sudo -u ereg tail -f /srv/ereg/httpdocs/protected/runtime/application.log

    Produces — a first page render.
    Time — 10 minutes.
    Check — the status code is 200 or a redirect, not 500. If it is 500, the application log names the cause. The three usual causes are a wrong database password, a missing PHP extension, and open_basedir not listing the file store.

  2. Test the three things that actually break after a move

    First, log in as a test user. That proves the database, the session table and the cookie settings. Second, open an existing document: pick any file and open an attachment. That proves the symbolic link, open_basedir and file ownership. Third, generate a certificate. That proves wkhtmltopdf, the fonts, and write access to the certificates folder.

    Time — 30 minutes.
    Check — all three succeed, and no new error appears in application.log.

  3. Test the outside connections

    The application reaches out to these. Test each one from the new machine.

    What it callsWhere it is configuredWhat breaks if unreachable
    The internal business registry backend, over XML-RPCprotected/components/DataExchangeHelper.php — the constants BACKEND_URL, BACKEND_DB, BACKEND_DB_USERNAME, BACKEND_DB_PASSWORDSubmitted files are never pushed to the registry. The application retries up to 10 times with a 3-hour delay, then gives up quietly. That is silent data loss. The credentials are hard-coded in this file — change them here and rotate them.
    A second XML-RPC endpointprotected/components/Odoo.phpThe same kind of push fails.
    SMTP relay on port 587protected/config/.envNo mail at all: no account activation, no notifications, no error alerts.
    Google Maps JavaScript APIprotected/config/params.php, gmaps_keyAddress maps do not draw. Cosmetic.
    A national data-exchange security server, and a reference-data serviceprotected/controllers/TestController.php onlyNothing. These appear only in test code that is not reachable in normal use.
    A tax web serviceprotected/components/ServiceDGI.phpNothing. Not used by this application.
    # adapt the host and port from the configuration files above
    timeout 5 bash -c 'cat < /dev/null > /dev/tcp/<BACKEND_HOST>/<BACKEND_PORT>' && echo reachable
    timeout 5 bash -c 'cat < /dev/null > /dev/tcp/<SMTP_HOST>/587' && echo smtp-reachable

    Time — 20 minutes, plus whatever the network team needs.
    Check — each test prints reachable. Where it does not, raise a firewall request before the cut-over. A silent failure here loses submissions.

9 · Phase 5 — Cut over

Steps 23 and 24. Two to three hours, then a 30-day wait before the source is handed back.

  1. Final catch-up, then switch

    Put the source site into maintenance, or agree a quiet window. Then, in order: re-run steps 8 and 9 for a fresh database dump, and step 16 to reload it; re-run steps 10 and 11 — the second pass only moves what changed, and takes minutes rather than hours; issue a TLS certificate on the new machine; and change the DNS record at the external provider to the new machine’s address.

    sudo certbot --nginx -d archive.monentreprise.bj

    Do not copy the source certificate. It is held inside the control panel’s own store and it will expire. Issue a fresh one.

    Produces — the site live on the new machine.
    Time — 2 to 3 hours, including the second database load.
    Check — curl -I https://archive.monentreprise.bj from outside returns 200 from the new machine. Confirm by comparing the certificate’s issue date.

  2. Keep the source server for 30 days, then hand it back

    Leave the source running. Do not delete it until all three of these are true: the new machine has completed 30 nightly backups; whoever administers the source has agreed to release it; and someone has confirmed the record counts still match.

    Time — 30 days of waiting, then a few minutes.

10 · Why rebuild, rather than migrate the control panel

Five reasons, strongest first.

  1. The new machine has to run one application, and only that.

    It is one site, one database, one file store and one nightly job. The rebuild copies a named list onto a clean machine and excludes the rest by pattern, so what landed there can be audited afterwards. A control-panel migration copies whole folders instead, and you inherit whatever is inside them.

  2. The PHP version has to be solved either way.

    The site runs on the control panel’s own PHP 7.4 build, and PHP 7.4 is past end of life. Check the control panel’s documentation for which PHP versions it packages for Ubuntu 24.04 before you count on a migration carrying 7.4 across; that could not be verified from the source server. If it does not, the migration lands the site on a PHP version it cannot run, and you hand-install PHP 7.4 anyway — the hard part of the rebuild, without the benefit of a clean machine.

  3. A control panel is a licence and a dependency you do not need.

    The application is one Yii 1 site, one database, one file store and one nightly scheduled job. nginx, PHP-FPM and MariaDB cover all of it. Adding a control panel adds a licence cost, another product to patch, and a second mail server, DNS server and FTP server you did not ask for.

  4. The application is plain PHP.

    No application file is ionCube-encoded; the loader on the source is a leftover. Nothing is tied to a specific machine or licence, so a plain file copy is enough.

  5. The source operating system is out of standard support, and the machine is short of disk space.

    Cloning that state forward carries both constraints onto new hardware. A clean Ubuntu 24.04 build starts without them.

What the rebuild costs you, honestly. You hand-write the nginx and PHP-FPM configuration in step 14, re-issue TLS in step 23, and lose the control panel that previous administrators used to manage mail and scheduled tasks. Two mailboxes exist on the source — a noreply address on each of two domains, holding 4 GB of mostly delivery reports. If anyone needs that mail, export it before the source is decommissioned. Everything else in the control panel is either unused or replaced above.

11 · If the test, dev and chat systems must move too

Only if item 2 of the confirm list says yes. Add these to everything above.

ItemSizeNote
Database ereg_benin_test1.4 GBFor test.benin.eregistrations.org
Database ereg_benin_dev1.6 GBFor dev.benin.eregistrations.org
Database ereg_benin_migration0.12 GBA one-off migration workspace, with no recent writes
Database siggufe_db0.11 GBHistorical, with no recent writes
Database keycloak0.02 GBSee the note below
/var/www/vhosts/benin.eregistrations.org/test.benin.eregistrations.org2.3 GBTest site code
/var/www/vhosts/benin.eregistrations.org/dev.benin.eregistrations.org3.3 GBDev site code
/mnt/volume-bj/test.benin.eregistrations.org/documents6.0 GBTest documents
/mnt/volume-bj/test.benin.eregistrations.org/certificats1.5 GBTest certificates
/opt/keycloak—The login server; see the note below
Four Docker containers23 MB eachStatistics, trade-name check, name-register update, investment desk. The production application calls three of them on localhost ports 3003, 3004 and 3005.

The keycloak database

The production archive does not use it. The database holds a realm with 4 028 user accounts and two client applications: the chat server, and one client whose redirect addresses point only at the test and dev sites. The production site authenticates against its own tbl_user table, and every external login provider is switched off.

If you are moving only the production archive, do not copy the keycloak database. If you are also moving the test site, the dev site or the chat server, copy it together with /opt/keycloak. It is a Keycloak 16-era server running on WildFly, bound to 127.0.0.1:8080. It runs on Java 11, which is not the default on Ubuntu 24.04, and that Keycloak version is long out of support. Plan to replace it rather than carry it forward.

The three helper containers matter more than they look

protected/components/AutomaticAction.php calls localhost:3003 and localhost:3004, and protected/models/TradeNameSearch.php calls localhost:3005. All three are on normal production code paths. If you move the production site without them, trade-name search and two automatic actions will fail.

Their source folders sit in the home folder: update-names-register, guichet-investissement, check_trade_name. They are small. Copy them, and run them with Docker Compose on the new machine, on the same local ports.