Skip to content

Instantly share code, notes, and snippets.

@JoelLisenby
Last active April 10, 2018 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JoelLisenby/4a3a88e1f0e33be86370a3366f6d6d12 to your computer and use it in GitHub Desktop.
Save JoelLisenby/4a3a88e1f0e33be86370a3366f6d6d12 to your computer and use it in GitHub Desktop.
WordPress Site Migration

WordPress Site Migration

Step 1: Backup Dev Site

  • dump database mysqldump -u user_name -p db_name > database_dev.sql
  • files_dev.zip/tar.gz all website files and folders zip -r files_dev.zip /var/www/
  • Store in directory outside of public directory cp files_dev.zip ~/site-backup/ && cp database_dev.sql ~/site-backup/

Step 2: Backup Live Server

  • dump database mysqldump -u user_name -p db_name > database_live.sql
  • files_live.zip/tar.gz all website files and folders zip -r files_live.zip /var/www/
  • Store in directory outside of public directory cp files_live.zip ~/site-backup/ && cp database_live.sql ~/site-backup/

Step 3: Copy Dev Backup to Live Server

  • preferably directly server to server, i.e. wget https://www.dev-site.com/backup_3848gjKGj5kgjLRGKJRSk.zip from the live server.

Step 4: Deploy New Site

  • Make sure index.html exists and is in the public directory. touch /var/www/index.html
  • Delete all other live files from the public directory. rm -rf /var/www/relevant_files
  • Drop all tables from live database DROP TABLE IF EXISTS table_1,table_2,table_3...
  • Extract dev files into public directory. unzip files_dev.zip /var/www/
  • Replace wp-config.php or edit wp-config.php to utilize the live database credentials.
  • Import database backup into database. mysql -u user_name -p db_name < database_dev.sql
  • Find and replace dev url with live url using a script which supports serialized data. Doing a find and replace directly within your text editor could break any serialized data stored in the database. Search Replace DB is one tool for the job which is designed to use the database stored in the WordPress wp-config.php download (source)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment