Cloning OpenResty Edge Environment

When facing scenarios such as the following, we may need to build an environment that is consistent or as consistent as possible with the production environment:

  • Upgrade testing: Before upgrading OpenResty Edge, build an environment that is identical to the production environment for testing. After passing the test, proceed with the upgrade of the production environment.
  • Migration upgrade: Instead of upgrading the production environment, build an environment that is identical to the production environment and upgrade and test the new environment. After passing the test, directly switch the traffic from the old environment to the new environment.

The detailed steps are as follows.

  1. Obtain a data backup from the production environment: log in to the Edge Admin DB machine, then confirm that there is enough disk space, and execute the following command for data backup:

    # PostgreSQL 12
    /usr/local/openresty-postgresql12/bin/pg_dump or_edge_admin -C -Upostgres | gzip > or_edge_admin-`date +%F`.gz
    
    # PostgreSQL 9
    /usr/local/openresty/postgresql/bin/pg_dump or_edge_admin -C -Upostgres | gzip > or_edge_admin-`date +%F`.gz
    

    After the data backup is completed and retrieved, no further operations on the production environment are needed in the subsequent steps. To prevent any mishaps, you can disconnect from the production environment.

  2. Install the same version of OpenResty Edge in your test environment as in your production environment. If you wish to test the deployment of OpenResty Edge in a Kubernetes environment, please refer to Deploying OpenResty Edge in Kubernetes; otherwise, refer to Installing OpenResty Edge.

  3. Import data into the new environment: log in to the Edge Admin DB machine of the new environment, upload the exported data to it, and execute the following command to rename the or_edge_admin database generated during installation and import the data:

    # PostgreSQL 12
    /usr/local/openresty-postgresql12/bin/psql -Upostgres -c "ALTER DATABASE or_edge_admin RENAME TO or_edge_admin_old"
    
    # PostgreSQL 9
    /usr/local/openresty-postgresql/bin/psql -Upostgres -c "ALTER DATABASE or_edge_admin RENAME TO or_edge_admin_old"
    
    # PostgreSQL 12
    zcat or_edge_admin-{date}.gz | /usr/local/openresty-postgresql12/bin/psql -Upostgres
    
    # PostgreSQL 9
    zcat or_edge_admin-{date}.gz | /usr/local/openresty-postgresql/bin/psql -Upostgres
    
  4. Then upgrade the new environment, see Upgrade OpenResty Edge

If you have any questions, please get in touch with us.