EE upgrade script
It’s not a magic bullet and still requires some manual intervention to complete an upgrade/update.
So what does this little script do?
It will back up some of your current installation’s files, create a new system folder, copy the new and backed-up files to the new location, and link your system folder to this new location. This will save you time and hassle, and keep it easy to roll back to the previous version if something goes wrong.
Before I get into all the technical aspects of the script, a bit of warning: Using this script does require shell access to your hosting environment and the ability to create folders above your public folder/document_root. You should be comfortable navigating the shell and command line.
I also want to give some credit to Mark Huot since the folder structure used is based on content in his Securing ExpressionEngine 2 book.
The folder structure
So let’s start by looking at the folder structure that makes all this function.

- ee – this is the symbolic link to your EE system folder, in this case the ee2.4.0 folder
- ee_upgrate.exec – the magic script
- ee2.4.0 – the EE system folder
- htdocs – the public folder (document root) for this site. Depending on your host it may be named public, httpdocs, or something else
- cp – the placeholder folder for CP access (there’s no need to use this, it’s just how we choose to do it … the admin.php file is sufficient)
- images – the EE images folder
- index.php – the EE index file
- themes – the EE themes folder
- libs – this is where I store my custom PHP classes and additional code
- src – where I keep the ZIP files for EE and temporarily unzip them (more on this later)
- templates – my EE template files
Using this approach, it will become easier to find what you need and keep your files separate from the EE core. Don’t forget to update your config file with the proper paths for system and template files.
This folder structure also improves security by keeping your core EE files outside of the publicly accessible folder. This helps prevent accidental access to your config files and other bits such as any custom code or SQL in your templates. To learn more about this approach and why it’s a good idea, check out Mark’s book or this article on EE Insider.
The upgrade process
So here we go, the upgrade process.
Step 0
Back up your EE database.
Step 1
Download the new version of EE and upload the ZIP file to your SRC folder.
Step 2
Log in to the shell for your site and unzip the EE ZIP file you just uploaded.
Step 3
Make sure the ee_upgrade.exec script is set to executable (chmod 755).
Run the script like so:
./ee_upgrade.exec <relative path to unzipped EE folder> <relative path to current EE folder> <name of new EE folder>
Example:
./ee_upgrade.exec src/ExpressionEngine2 ee2.3.1 ee2.4.0
This will upgrade using the new files in src/ExpressionEngine2. Copy the needed bits from the ee2.3.1 folder into the new destination folder ee2.4.0 and link the ee folder to the ee2.4.0 one.
Step 4
Follow the usual upgrade process as described in the EE docs beginning at “Run the Update Wizard”.
Step 5
Enjoy your upgraded site!
Download
NOTE: Use this script at your own risk. I make no guarantees and cannot be held responsible for any issues or loss of data.
Also included is a simple build update script as a companion. Leave a comment with any feedback or if you run into any problems, please use Twitter (@fredboyle) to reach out to me.

Comments
Nice one. Correct me if I’m wrong, but this gets even a little easier now that the third_party folder can be pulled out of system/ (in 2.4.0). You could put third_party above the doc root too.
Is rolling back as easy as pointing your ee symlink at the ee2.3.1 folder and restoring the db from backup?
Jason, I haven’t messed around with moving the third_party folder yet but from what I’ve read it could indeed be moved above the doc root.
Rolling back your EE version is indeed just a matter of pointing the symlink and restoring the db. However keep in mind that your templates are separate so version specific changes could cause problems.