Transferring a WordPress site to the live server

Copy the current live site

First we need to make backups of all of our sites. Open Terminal on the computer, ssh to info and info-dev, then use this command to pull the wp-content directory from each server to the computer desktop (this is the dry-run command, obviously run it again for real once you’re sure it is doing what you want).

rsync -arvz --dry-run greatwmc@info.jmu.edu:/var/www/html/uinfo/wp-content/uploads/sites "/Volumes/OPTIMUS PRIME/web_backup_mar31_17/"
rsync -arvz --dry-run greatwmc@info-dev.jmu.edu:/var/www/html/uinfo/wp-content/uploads/sites "/Volumes/OPTIMUS PRIME/dev_web_backup_mar31_17/"

Delete the –dry-run piece to actually run the code.

Now Backup the databases

Navigate i browser to http://info.jmu.edu/phpmyadmin/index.php

Login with milesgwood and password sent in slack

Then get the site ID’s by hovering over their names. On dev Madison society is 11. On live MS is site 11 as well.

First download an SQL backup of the entire database. Then download the specific site you want to transfer. In this case that is site 11. For sites that already have plugins and are using their live sites, make sure to not overwrite their good content. For us gravity forms is the only one. It is the only front end content.

Move the media library using Coda 2 FTP

The content is stored in the media library. Change the permissions so that apache is the owner and unionsweb the group. These changes occour at the sites folder level where you can see all the site folders like folder 11 12 22 etc.

sudo chmod -R 775 11/
sudo chown -R apache 11/
sudo chgrp -R unionsweb 11/

Overwrite the database on live

Simply import the tables you exported from the dev site. Make sure that the export on the dev database includes the Drop table checkbox.

Fix the file paths

Database Search and Replace Script

Throw the script into the /var/www/html/uinfo directory and run it correcting the file locations. Navigate to the folder that you put it in, in the browser and the index.php will display the script.