TL;DR: CEM CLI is a cPanel to EasyEngine Migration CLI. It’s quite new at the moment and is meant to automate bits of the repetitive tasks that one has to go through while migrating their sites from a cPanel based shared hosting (with no SSH access) to an EasyEngine based rented self-managed VPS.
I had a few small low-traffic sites sitting on a shared hosting account with cPanel (no SSH access) for quite some time now. I have been meaning to transfer them to a self-managed cloud but it’s hard to find enough time these days.
Anywho, I have tried EasyEngine script (built by rtCamp) in the past and I liked everything about it. So, I ended up building a migration CLI which BTW can also be used as a command line tool to build a staging website for a website you host on a shared server.
DevOps (a clipped compound of development and operations) is a culture, movement or practice that emphasizes the collaboration and communication of both software developers and other information-technology (IT) professionals while automating the process of software delivery and infrastructure changes. — Wikipedia.
I have always been a workflow-optimist. What that means is whenever I have to perform a task repeatedly, I find a way to make it more efficient, which in turn means automation, and hence I always end up building a pro workflow for that task.
I guess developers are like that. We hate repetitive nature of any process. I do. I believe that software development is not just my career — it’s a way of life.
More often than not I find myself in an if/else-if/else situation, whenever life throws a curveball I end up with switch-case, and then there are these things in my life which have a repetitive nature — Maybe it is my OCD (Obsessive-Compulsive Disorder) that compels me to do what I do — but then I start thinking about the repetitive task at hand, I study its patterns and then I try to automate it as much as I can.
That’s exactly how CEM CLI came into being.
Do you have OCD? Does the need of keeping things in check sound familiar? Do you build little workflows — tell me about that in the comments below.
Anywho, let’s get to the CEM CLI part before I start talking more about my OCD.
Running this CLI will output several questions on your terminal. Each question comes with an example value enclose with square brackets . Just fill up the answers and you’ll be able to automate bits of the complete migration process.
Yes, I get that. This script is quite opinionated and in the beta stage. While I have released v1.0.0 it still needs to be tested and I plan to maintain and grow it. If you are wondering how it works, here’s a step by step guide.
While the CLI migrates your site for you, this following things happen.
CEM CLI Downloads the backup in a folder you specified (I recommend running CEM CLI from the root i.e. cd ~).
Then CEM CLI extracts the backup inside a folder called backup.
After that CEM CLI runs EasyEngine to install your site from the scratch (You need to edit EasyEngine’s configuration file to make sure EasyEngine should ask you for entering the Database Name, Database Username, Database Password, and Database Prefix. You should enter all of these values similar to what you have in your wp-config.php on your old server. This is a crucial step. Otherwise, you won’t be able to import your old database).
Then CEM CLI installs a new WP site for you with only --wp parameter set.
After that it uses rsync to copy/sync your WP Site’s files from your backup to the EasyEngine site install location i.e. from sitefolder/backup/homedir/public_html/ to /var/www/domain.com/htdocs/.
Then CEM CLI uses WP CLI to import your old database into the new sites database with --allow-root parameter.
After that you can get an option to search and replace any string in the DB to go through with the migration. This is also powered by WPCLI and uses --allow-root parameter for now.
Once all of this is done your site sits in the /var/www/domain.com/ folder. In case you want to use WPCLI to do something else, you can cd to /var/www/domain.com/htdocs/ path.
If you edit your systems host files nano /etc/hosts and append XX.XX.XX.XX domain.com www.domain.com at the end, then you can browse your migrated site to check if everything is running fine. (XX.XX.XX.XX is the IP of your server. I found out that if I flush the DNS cache in my mac then I can avoid the delay for the hosts file edits to take effect. You can flush your DNS cache by running this command on your mac sudo killall -HUP mDNSResponder).
cemcli removes the backups both extracted and tar files as soon as it can to save as much space as possible.
While CEM CLI is no where near an ideal script, it helps me migrate/stage my sites on self-managed VPS. I plan to improve this script by adding several new routines to it. Following is a list of ideas that I have.
[x] Download Backup
[x] Extract Backup
[x] Migrated site creation
[x] WP Files sync
[x] WP DB import
[x] Search and Replace
[ ] SSH transfer
[ ] Site sync via NCFTP
[ ] Options to chose how to perform backups
[ ] Better install and uninstall routines
[ ] Mold it into EasyEngine’s CLI instead of just a migration CLI (Thinking Out Loud)
Make sure to test this CLI on a new server. It is beta and completely new. I have tested it to transfer my cPanel sites to an EasyEngine VPS (based on Ubuntu 16.04 x64) while working on a Mac. Use at your own risk 🤔.
Takeaway my professional opinion on open-source, developer relations, growing your business with family, and everything in between! Delivered to your inbox a couple of times every year. I'm even funny at times. I hate spam — pinky-promise!