- 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/
- 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/
- preferably directly server to server, i.e.
wget https://www.dev-site.com/backup_3848gjKGj5kgjLRGKJRSk.zip
from the live server.
- 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)