Site Factory

Restoring a site from a backup

Site Factory provides two types of backups from which you may restore:

Restoring from an on-demand full backup

After you create a backup of one of your Site Factory-hosted websites, you can then restore the website from its backup. Restoring a website from a backup creates a new website, which you can then add to the same group and site collection as the website from which you created the backup. The original website, the source of the backup file, remains unchanged.

To restore a new website from a backup:

  1. Sign in to the Site Factory Management Console.

  2. On the All my sites page, click All my backups.

  3. On the Site Backups page, locate the backup from which you want to create a new website. You can sort the backups by date, backup name, components, or stack.

  4. Click Restore.

  5. In the New site name field, enter the new website’s name using only lowercase letters and numbers, ensuring you don’t use the name of another Site Factory website.

  6. In the Backup file components section, select the components you want to restore from backup. To create a new website, you must select the database option.

  7. Click Restore.


Restoring a website can take several minutes to complete for small websites, but larger websites can take much longer to complete.

Site Factory will notify you by email after the restoration completes. You can add the new website to a group or site collection, and make the new website the primary website for its site collection (in place of the website whose backup you used to create the new website).

Restoring from a nightly database backup


Site Factory non-production environments don’t make automated daily backups. Site Factory subscribers must create on-demand backups if necessary for their development process.

To restore a nightly database backup, either use the Cloud Platform interface or use the command line.

Restoring from the Cloud Platform interface

To restore a nightly database backup using the Cloud Platform interface:

  1. Sign in to the Site Factory Management Console.

  2. Identify the website for which you want to restore a database, and then point to the Information icon to display the DB Identifier value.

  3. Identify the database backups matching the DB Identifier value from the previous step, and then perform the restoration as described in Restoring database backups.

Restoring from the command line

ADVANCED - Incorrectly restoring a database can cause data loss or website downtime. For help restoring a database, contact Acquia Support.

To restore a nightly database backup for a single website from the command line:

  1. SSH into your environment.

  2. Navigate to your backups directory with the following command:

    cd /mnt/files/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/backups
  3. Create a new database backup of the website you intend to restore by running the following command (where [SITEURL] is the URL of your website):

    drush -r /var/www/html/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/docroot  --uri=[SITEURL] sql-dump --gzip --result-file=/mnt/files/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/backups/site-backup.sql
  4. Confirm a valid backup exists by executing the following command to confirm a file matching the name site-backup.sql now exists in the directory:

    ls "`pwd`/site-backup.sql.gz" /mnt/files/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/backups/site-backup.sql.gz
  5. Identify the database name and site path values by executing the following command, substituting the [SITEURL] value with the URL of the website you want to restore:

    drush -r /var/www/html/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/docroot --uri=[SITEURL] st | grep -E "Database name|Site path"
    Database name : customeracsdb123102
    Site path : sites/g/files/marketing101

    In the preceding output, your database name is customeracsdb123102 and your path is marketing101. You will need these values in the following steps.

  6. Identify the file name of the database backup by using grep in your backups directory to search for the available database backup files matching the site path you identified previously, replacing [PATH] with your path:

    ls -lath | grep [PATH] | head

    The command returns a list of the database backups available for restoration.

    -r--r----- 1 customername www-data 12M Dec 17 08:16 01live-marketing101-customerdb123102-2017-12-17.sql.gz
    -r--r----- 1 customername www-data 11M Dec 16 08:16 01live-marketing101-customerdb123102-2017-12-16.sql.gz
    -r--r----- 1 customername www-data 11M Dec 15 08:16 01live-marketing101-customerdb123102-2017-12-15.sql.gz
  7. Run the following command to extract the filename of the backup you want to restore, replacing filename.sql.gz with the name of your file:

    gunzip filename.sql.gz
  8. Ensure the .sql file extracted correctly, and check the full path of the resulting .sql file by executing the following command, replacing filename.sql with the name of your file:

    ls "`pwd`/filename.sql"

    If the file system path to your newly-extracted .sql file is not in the output of your command, confirm the file extracted successfully before continuing to restore the backup. If unsure, contact Acquia Support.

  9. Drop the existing database.


    Dropping the database destroys all data stored in the website’s current database. After executing the command, your website will be inaccessible until the database restoration completes.

    To drop the existing database, execute the following command (where [SITEURL] is the URL of your website):

    drush -r /var/www/html/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/docroot --uri=[SITEURL] sql-drop

    Drush will display the following confirmation message to confirm you intend to drop the database:

    Do you really want to drop all tables in the database
    customeracsdb1231023? (y/n):

    If the database name matches the database name you identified in Identify the database name and site path values, press Y to drop the database.

  10. Restore the database backup you identified by running the following command, using the full path to the .sql file you confirmed when preparing the database backup file for restoration:

    drush -r /var/www/html/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/docroot --uri=[SITEURL] sqlc < /full/path/to/backup/filename.sql


    • [SITEURL] - The full URL of your website

    • /full/path/to/backup/filename.sql - The full file system path to your .sql backup file

Your database restoration is now complete.