To move a Drupal 8 Development site into Production (Shared Host)

Disclaimer: This worked for me on my shared hosting environment, it may not work in every hosting situation… It is the result of a long process of seeking help from many sources! – Always make backups!

To move a Development version of a Drupal 8 website on a Shared Server into a Production environment, while retaining the development copy for online testing and further development.

(This assumes that you have built your development website in a subdomain and that you have SSH, and cPanel privileges and a phpMyAdmin or comparable database tool. It also would help to have Drush installed)

1) Create a new Subdomain to temporarily house your files.

2) Make a backup archive of your database and files.
     a) I used the drush command:
#drush archive-dump
     b) Alternatively, it may also be possible to install and use the module, “Backup & Migrate” for this purpose.

3) Using ftp, sftp, cPanel or otherwise, copy that archive dump file into the newly created directory.

4) in phpMyAdmin go to your existing (Development) database and “Operations > Copy database to”
     a) enter the name of the new (Live) database you wish to use eg: ‘username_website_live‘.
     b) Alternatively, you may create an empty database with that name and import the data from your Development site!

5) Using Drush
     a) #drush archive-restore BACKUPNAME.tar.gz
     b) This will recreate your files in the new directory. (Be patient, it could take some time)

6) Edit /site/sites/default/settings.php to reflect the new database name and login info:
'database' => 'username_website_live',
'username' => 'your_database_username',
'password' => 'your_database_password',

7) In phpMyAdmin, go to your newly created database and “empty” (TRUNCATE) all tables beginning with “cache”.
     a) There are several methods for this operation, I simply checked those tables and selected “Empty”

Then go to the new Subdomain in your browser and the “cloned” site SHOULD be working (Login as Admin and look around)…

If instead you get the error, “The website encountered an unexpected error. Please try again later.” you may need to retry to clear the cache tables again or using another method…

Possibly Use the Drush command #drush cache-rebuild to clear and rebuild all cached data for the site. After running this command, you will see the output message “Cache rebuild complete.” 

8) To move the now working version into Production, you may now rename the Directory that is housing your new (Production) version in accordance with your hosting system ie: ‘home/user/public_html’ or ‘/www’ (consult your hosting provider).

However it may be necessary to use an .htaccess file with a rewrite rule to point your base URL to the “site” directory!

Good luck!

Drupal version: