Restore Concrete5 backup after failed upgrade
Goal: To revert your Concrete5 website to a former state via a backup that you had previously taken
Prerequisites: Obviously in order for this to work you will need to have taken a backup of your Concrete5 website. Another thing that you will need to know is what Concrete5 version you were on when you took the backup (this can also be found by restoring your MySQL backup and looking in the config table).
WARNING: In the event you did NOT take a backup of your database prior to upgrading, do so immediately by whatever means available. At this point you may have lost data or ended up with a corrupt database and you should seek professional help. Please see our additional help section at the bottom of this tutorial.
It's not uncommon that when upgrading your Concrete5 site you get done with your upgrade, and errors appear on the page. There are many reasons this can happen, perhaps your memory limit isn't high enough, or maybe you ran out of disk space on your hosting account, or maybe there was some bug in Concrete5 that prevents you from skipping from one version to another without going through some intermediate version manually. As unfortunate as this all is, to date it has always been possible to upgrade to a later version (even if it does require a bit of effort), and to be prepared for cases like this you should ALWAYS take a backup prior to upgrading your site.
With that said lets begin our restore.
Restore the Database
- If you used the built in Concrete5 backup tool prior to running your upgrade you will need to go and download a copy of the .sql file that was created. This file can be found using an ftp client or file manager that your web host provides. Here we use CPanel's file manager to go and download a copy of this file from
/files/backups/dbu_*.sql. If you have multiple backups then you can look at the date on the file to help determine which one you want to restore.
Note: You should NOT keep these backups sitting out here as it poses a potential security risk in the event that the file permissions are ever changed.
- Once you have this file downloaded (note that downloading the file may require you to change the file permissions) then you will need to navigate to your favorite MySQL database tool that is capable of importing the .sql file (In this case and most others you can use PHPMyAdmin which is most likely accessible via your web hosting control panel).
To do this, we'll open the database in PHPMyAdmin we wish to restore, then we go to the "Import" tab, attach our file and hit "go". Since the Concrete5 sql file that gets created drops the tables if they exist we don't have to worry about cleaning anything up ahead of time.
Change the Configuration File
When you run a Concrete5 upgrade, it creates a second copy of all the core files, this way it can simply point your installation at this new copy of the files and in the case of failure you just have to point it back at the old files (this is why knowing what version you were on prior to your upgrade is important). In this example, I was trying to upgrade from 22.214.171.124 to 126.96.36.199. Now in order to revert my install back to 188.8.131.52 I have already re-loaded my database (above) and now I need to change my configuration file to point to the appropriate directory.
- To determine where you need to point your install to, the first thing you need to do is check in the /updates/ folder in your site root. Does your version you were upgrading from exist there? If so then copy the directory name, you will need that in the next step. If it doesn't exist there then it means that you were previously just pointing your install at the /concrete directory (which will also be explained in the next step.
In my instance, I have the version I was upgrading from (184.108.40.206) in my /updates/ directory (see screenshot) and it was called concrete220.127.116.11_updater (remember the folder name as it is important for later).
- Now find your way over to /config/site.php. Inside of this file you will find your database connection information, and possibly some other application configurations. What we need to change (or remove) here is the line for the constant
<?php define('DIRNAME_APP_UPDATED', 'concrete18.104.22.168_updater');?>You'll notice that this is probably trying to point at the directory that you were attempting to upgrade to. Now, if you did not have your previous version in the updates folder, you are safe to simply remove this bit of code from your configuration file, that will point your install to use the /concrete directory as the core again. If you did have your previous version in the updates folder though, change the second argument of the define function to be the directory name (in my case I will change it to be "concrete22.214.171.124_updater" and in the end my config file will look something like this:
<?php define('DB_SERVER', 'localhost'); define('DB_USERNAME', 'c5helpuser'); define('DB_PASSWORD', 'redacted'); define('DB_DATABASE', 'exchange_c5help'); define('PASSWORD_SALT', 'redacted'); define('DIRNAME_APP_UPDATED', 'concrete126.96.36.199_updater');Note: You should take special care to make sure there are no blank lines or whitespace at the end of your site.php file. If there is it can cause images to not display on your website or cause warnings to show up on your site.
And with that you should be reverted back to your previous version and your site should be running again.
Need Additional Help?
In the event that you need additional help with your installation there are several resources available to you.
- First and foremost the Concrete5 community. Create an account on www.concrete5.org and post to the forums with any problems you might run across. This helps alert the developers of problems people are having so that the product can be made better or more user friendly in the future.
- Secondly, contact your web host. Often times the updater may error due to php not being configured with enough memory or perhaps it's not running the right version. These are things that your web host should be able to help you address.
- Thirdly, please feel free to contact ExchangeCore's development team. I list us as the last option because while we know what we're doing, we also come at a price and we hate to see you throw money away when there are other options. That said there are some pretty tough cases and if you do need our help, we can be reached by visiting our Development Contact Page.