Kickassd Knowledge Base

Migrating Wordpress Like A Pro With SSH

     

    Migrating your Wordpress site with SSH can streamline things, avoid some potential issues, and well it is by far the coolest way to migrate your Wordpress site. it is also very fast and will save you a ton of time on larger sites. Server to server is much faster than server > your desktop > server.


    Things You Will Need

    - SSH access on both accounts
    - If on Windows a SSH client such as Putty
    - 30 minutes of your time

    If you do not know how to use SSH here at kickassd please read:
    Setting Up SSH Access At Kickassd


    Setting Up Keys

    This is similar to the above guide but instead of setting up keys on your computer and server, you are instead setting up for server to server access, which is easy enough.

    On the origin server you should already have a key created and access granted. Copy the private key and than go to the destination server > Manage Keys > Import SSH Keys. Choose a name in the format of keyname_rsa, than paste the private key in the box and enter it's password if it has one.


    Backing Up Site On Current Provider

    Now what we will do is zip your current Wordpress site as well as dump the associated database. If your site is installed in your main domains public_html and not a sub-folder we can zip public_html. Do this by typing "zip public_html".

    Now we can scp copy the .zip over to the destination server by using the following commands:

    cd
    cd .ssh
    scp -P 1022 -i destination_rsa /home/cpanelname/public_html/site.zip cpanelname@yourdomain.com:/home/cpanelname


    This Command Explanation

    scp -P 1022 -i destination_rsa /home/cpanelname/public_html/site.zip

    This defines port (-P 1022) key (-i destination_rsa) and location of file to transfer (/home/cpanelname/public_html/site.zip). You need to replace "cpanelname" with your actual cPanel username which is what you use to login to cPanel, this should also be visible in SSH (name@servername).

    cpanelname@ssh.kickassd.net:/home/cpanelname

    This defines user to connect as on the destination server and the location to put the transferred file. Again change cpanelname to your cpanel username on the destination server and change the domain to your domain. If your domain does not yet resolve to our servers than you can use the server IP.

    If all goes well the transfer should complete and it is time to move on to the Database dump and transfer. You should remove that .zip so type rm site.zip


    Database Dump And SCP Transfer

    First do the dump on the origin server:

    mysqldump -u cpaneluser -p --opt [database name] > [database name].sql


    Replace cpaneluser with your cPanel username and get rid of the []. Once the command runs if all is well you should now have the .sql file in your current directory, check by typing ls and see if it exists.


    Now we will scp transfer that .sql file:


    cd

    cd .ssh
    scp -P 1022 -i destination_rsa /home/cpanelname/sqldump.sql cpanelname@yourdomain.com:/home/cpanelname


    You should now have the sqldump.sql on the destination server. Let's login to SSH on the destination server, you can login direct from the origin server or open a new SSH from your desktop, I prefer the easy way :)


    ssh -i destination_rsa cpanelname@yourdomain.com -p 1022


    Creating Database, And User On Destination Server

    We will need to login to cPanel on destination server to do this. I will not detail this process here, just create a database, user, assign user to database, and grant all permissions. Once done back to SSH on the destination server and type:


    mysql database_name -u database_username -psqluserpass < sqldump.sql


    Now lets unzip your actual Wordpress files:

    unzip site.zip -d public_html


    You will now have a directory in your public_html that contains all your site files. If you need to move those files let's say into public_html so your site is available on your main domain name, you can move them like so:


    mv public_html/directoryname/* public_html/


    Now you will want to make the appropriate changes in your wp-conf file, so type nano pathto/wp-config.php.


    You will need to change the prefix on database name, database username, and the password as well if you made a different one.


    That's it you just migrated your Wordpress site like a pro! It seems a bit much at first but after you do it a time or 2 this is a super efficient and fast way to migrate.

     


Was this answer helpful?

 Print this Article

Can't find what you are looking for? Create a support ticket and our support team will be happy to help!