Search Engine: Elastic

Article ID: 129563, created on Oct 4, 2016, last review on Jul 14, 2018

  • Applies to:
  • Operations Automation


An APS 1.2 of Shared type (Site Application) was accidentally de-provisioned from a subscription. How to restore the application to the previous working state?


Restoration requirements:

  • available backup of the webspace from the date before the accident
  • available backup of the application database

Step-by-step procedure for a single subscription, ID 1000001 is used as an example.

  1. Get the webspace ID of the subscription in PCP > Services > Web Hosting > Apache Webspaces. Alternatively it can be fetched by pem.getWebspacesList API call. script may help:

    [root@osscore ~]# python 1000001
    2016-10-04 21:00:39.460 DEBUG call method pem.getWebspacesList({'subscription_id': 1000001, 'txn_id': '1434510598'})
    2016-10-04 21:00:40.008 DEBUG return {'status': 0, 'result': [{'path': '/var/www/vhosts/100001/', 'webspace_id': 100001, 'domain_id': 3, 'host_ip': '', 'domain_name': ''}]}
    2016-10-04 21:00:40.060  INFO Subscription 1000001 webspaces are:

    Note: there is 1 webspace per subscription in the majority of cases, so 1 entry is returned as a result of the API call. But in some rare cases, there could be more than 1 webspaces.

  2. Check APS package version in the webspace backup:

    [root@web1 ~]# egrep '<version>|<release>' 12321/backup/siteapps/MyApp-12321/APP-META.xml

    In case the version does not match the current top enabled version as seen in PCP > Services > Applications > MyApp > Versions, then disable all versions higher than the required one. Revert these changes after step 4.

  3. Make sure the resource limit for this APS application is not 0 and allows installing it.
  4. Login to CCP > Websites > > Web Applications > Install, pick MyApp.
  5. Determine the configuration file to get the details of the application database on the newly provisioned instance. Go to CCP > More Services > Databases, pick the database that was created most recently, its name is formed as db<subscription_id>_sa<app_instance_id>, example: db1000001_sa12322. Then search for this name in the file hierarchy of the application:

    # grep -l db1000001_sa12322 /var/www/vhosts/1/100001/siteapps/MyApp-12322/*

    Get the DB access details from this file:

    define('DB_SERVER', '');
    define('DB_USERNAME', 'u1000001_sa12322');
    define('DB_PASSWORD', 'password');
    define('DB_DATABASE', 'db1000001_sa12322_main');

    Note: different applications may have similar definition data stored in different files and in different format.

  6. Restore the old application instance database backup into the newly created database. Make sure that the database dump does not include CREATE DATABASE $db_name and USE $db_name lines.

    # mysql -u u1000001_sa12321 -p'password' db1000001_sa12322_main < db1000001_sa12321_main.sql
  7. Back up the DB definition configuration file and restore the content of the site application files from the webspace backup:

    # cp -arf /var/www/vhosts/1/100001/siteapps/MyApp-12322/htdocs/config.php MyApp-12322.config.php
    # cp -arf /path/to/webspace/backup/siteapps/MyApp-12321/* /var/www/vhosts/1/100001/siteapps/MyApp-12322/
    # cp -arf MyApp-12322.config.php /var/www/vhosts/1/100001/siteapps/MyApp-12322/htdocs/config.php

    Note: in case of several configuration files with DB access definition, backup them all before restoring files and put them back afterwards

  8. Make sure the permissions are correct for the restored files:

    [root@web1 ~]# ls -ald /var/www/vhosts/1/100001/webspace/httpdocs
    drwxr-x--- 3 a100001 pemsrv 4096 Oct  3 16:29 /var/www/vhosts/1/100001/webspace/httpdocs
    [root@web1 ~]# chown -R a100001:pemcln /var/www/vhosts/1/100001/webspace/siteapps/MyApp-12322
  9. Reset the application admin user password in CCP > Websites > > Web Applications > MyApp > Configure > Generate > Submit.

  10. In case of non-default URL path, it can be configured according to the backup files. The configuration will usually be stored in config.php or a similar file, e.g.:

    define('BASE_URL', '');
    define('DIR_REL', '/MyApp');

5356b422f65bdad1c3e9edca5d74a1ae caea8340e2d186a540518d08602aa065 e12cea1d47a3125d335d68e6d4e15e07

Email subscription for changes to this article
Save as PDF