---
title: "Restoring a site from a backup"
date: "2024-02-14T06:18:38+00:00"
summary: "Learn how to restore your Site Factory website from daily database or full on-demand backups. Follow step-by-step instructions for seamless restoration using the Cloud Platform interface or command line, ensuring data safety and minimal downtime."
image:
type: "page"
url: "/site-factory/restoring-site-backup"
id: "d8127f01-715e-4c8f-b8f6-8e974cdbf906"
---

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

*   [Daily database-only backups](#acsf-restore-nightly-db): Contain only a daily snapshot of a website’s database, but not the docroot directory, public files, or private files
    
*   [On-demand full backups](#acsf-restore-on-demand-backup): Contain a single website’s complete docroot directory, database, public files, and private files, as described in [Backing up sites](/site-factory/manage/website/backup)
    

Restoring from an on-demand full backup
---------------------------------------

After you [create a backup](/site-factory/manage/website/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](/site-factory/login) 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**.
    
    ![Restoring a new site from a backup](https://acquia.widen.net/content/uf3mnwzcbs/jpeg/site-factory_restoring-sites.jpeg?position=c&color=ffffffff&quality=80&u=u1mnox)
    
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**.
    

Note

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
----------------------------------------

Important

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](#acsf-restore-db-ui) or use the [command line](#acsf-restore-db-cli).

### Restoring from the Cloud Platform interface

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

1.  [Sign in](/site-factory/login) to the Site Factory Management Console.
    
2.  Identify the website for which you want to restore a database, and then point to the **Information** ![Info icon](https://acquia.widen.net/content/ayhya3e5m4/jpeg/site-factory_info-icon.jpeg?position=c&color=ffffffff&quality=80&u=u1mnox) 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](/acquia-cloud-platform/manage-apps/back-up#cloud-restore-db-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](../../../support.html#contact-acquia-support).

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

1.  [SSH into your environment](/acquia-cloud-platform/manage-apps/command-line).
    
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"
        
        /mnt/files/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/backups/01live-marketing101-customerdb123102-2017-12-17.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](/service-offerings/support#contact-acquia-support).
    
9.  Drop the existing database.
    
    Important
    
    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](#acsf-identify-db-name-site-path), 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](#acsf-identify-path-to-dumpfile):
     
         drush -r /var/www/html/${AH_SITE_GROUP}.${AH_SITE_ENVIRONMENT}/docroot --uri=[SITEURL] sqlc < /full/path/to/backup/filename.sql
     
     where:
     
     *   `[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.