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 Love Automation β Workflow Optimist!#
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.
I am an end to end product developer. Three years ago, I started to pick up on what we call DevOps.
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.
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.
Introducing CEM CLI#
cPanel to EasyEngine Migrate CLI (CEM CLI) is a bash script built to help people migrate their sites from a cPanel to a rented VPS with EasyEngine installed on it.
Pre-requisite#
You need to rent a VPS with EasyEngine installed on it. Here’s the list.
- Rent a VPS preferably with Ubuntu 16.04 x64 OS (I recommend Vultr.com | During summer, by using my affiliate link you get $20 Signup Bonus or if you prefer non-affiliate link)
- Install EasyEngine just run this command after logging into your VPS with SSH
wget -qO ee rt.cx/ee && sudo bash ee
Using CEM CLI#
After you have completed the pre-requisite steps, all you need to do is download and run the cPanel-EasyEngine-Migrate-CLI. You can do that by running the following commands.
Download cPanel-EasyEngine-Migrate-CLI
sudo wget -qO cemcli https://git.io/vPO0q && sudo chmod +x ./cemcli && sudo install ./cemcli /usr/local/bin/cemcli
Run cPanel-EasyEngine-Migrate-CLI
cemcli
To Uninstall cPanel-EasyEngine-Migrate-CLI
rm /usr/local/bin/cemcli
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.
How To?#
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.
Step #1: VPS#
Rent a VPS preferably with Ubuntu 16.04 x64 OS (I recommend Vultr.com | During summer, by using my affiliate link you get $20 Signup Bonus or if you prefer non-affiliate link)
Step #2: EasyEngine#
Install EasyEngine and run this command after logging into your VPS with SSH wget -qO ee rt.cx/ee && sudo bash ee
Step #3: Backup#
Take a backup of your cPanel. I prefer taking a complete backup and that’s how this script works.
- Go to your site’s cPanel > Backup Wizard
- Click Backup, then Full Backup and finally click on Generate Backup
- Once the backup is generated, go to File Manager
- Rename the backup file to something simple like bc.tar.gz
- Move the backup file to
/public_html/
folder
- Set the world read permission so that it can be downloaded via wget
You can watch all these steps in this short video which can be found at the end of these steps.
Step #4: Run CEM CLI#
- It’s time to run the CEM CLI. Log in to your VPS via SSH.
- Install CEM CLI by running install command as mentioned above command.
- Then run
cemcli
command and start answering the questions as I did in the video below.
Step #5: What you need to know!#
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.
Step #6: Watch How It’s Done#
You can either try to guess how it’s done with the GIF below or Watch a 2 min video on YouTube.
What Does Future Hold for CEM CLI?#
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)
Disclaimer (Beta Software)#
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 π€.
Version 1.1.1 β 2016-10-09#
Version 1.1.0 β 2016-10-05#
- NEW: Sub domain migration.
- NEW: Detailed documentation.
- NEW: Timely memory and space management.
- FIX: Minor fixes.
Version 1.0.1 to 1.0.9 β 2016-10-04#
- NEW:
cemcli
removes the backups both extracted and tar files as soon as it can to save as much space as possible.
- FIX: Several minor fixes and documentation.
Version 1.0.1 β 2016-10-04#
- NEW:
cemcli
removes the backups both extracted and tar files as soon as it can to save as much space as possible.
Version 1.0.0 β 2016-09-25#
- First version
- NEW: Backup download and extraction
- NEW: Migrated site creation
- NEW: WP Files sync
- NEW: WP DB import
- NEW: Search and Replace
This open source project is maintained by the help of awesome businesses listed below. What? Read more about it β
For anything else, tweet at @MrAhmadAwais
?Β Looking forward to the feedback and contribution from your end. That’s how we can make it something more worthwhile. Let’s collaborate at
GitHub.
βοΈ Did you like CEM CLI? It’d be great if you can share it on
Twitter.
007
what do you use to make 2 min long gif?
Ahmad Awais
I have a little workflow for that as well. It goes from recording everything in ScreenFlow and using three Node packages to convert and optimize it into a GIF. I’ll write about it here.