Migrating wordpress and the server

I migrated the site to a different server earlier this evening; let’s recap. Things in ”s are commands to be run.

  1. Log into your new server
  2. ‘screen bash’ (in case your net drops)
  3. ‘scp -R existing_website_name:~/destinationfolder folder_to_be_copied’ (the new setup will be /home/yourname/destinationfolder/folder_to_be_copied)
  4. hit ‘CTRL-A d’ (detach screen)
  5. hang out on IRC while your data transfers, check in every once in a while
  6. Next up is backing up the existing database – ssh into your existing server, then dump your database using ‘mysqldump -h hostname -u username -p databasename | bzip2 -c > dump.bz2’
  7. exit ssh and ‘scp existing_website:~/path_to_dump/dump.bz2 dump.bz2’
  8. log into mysql, then create your wordpress db user and your wordpress db, and then grant necessary privileges
  9. log out of mysql, and extract your database dump, then restore it by calling ‘mysql -h hostname -u username -p databasename < dump'
  10. change your wordpress directory’s ownership to the user who runs the webserver – probably www-data, by using ‘chown -R www-data directory’
  11. test everything out, make sure your new site is operating the way you’d expect
  12. change over your zonefiles to update your DNS.

In the middle of this, I had some extra steps:

  1. Get frustrated that I don’t have ‘interactive autocomplete’ turned on. In order to make screen autocomplete when I type ‘screen -r’, I have to enable bash_completion. I just copied a friend’s .bashrc and .bash_profile to make this work — I love having smart friends. The relevant lines in each of them are:
  2. .bash_profile:

    # include .bashrc if it exists
    if [ -f ~/.bashrc ]; then
        . ~/.bashrc


    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
  3. screen -r <TAB> to reattach my last screen session

And it’s all working well!

Leave a Reply

Your email address will not be published.