Quick code

RewriteEngine On
RewriteCond %{DOCUMENT_ROOT}/maintenance.html -f
RewriteCond %{REQUEST_FILENAME} !/maintenance.html
RewriteRule ^.*$ /maintenance.html [L]

Migration workflow

  1. Reduce DNS TTL to 5 minutes
  2. Configure destination server matching source settings
  3. Prepare maintenance rules in source vhost
  4. Execute initial database dumps and rsync transfers
  5. Verify functionality via modified hosts file
  6. Perform intermediate and final database/file syncs
  7. Create maintenance page on source
  8. Switch DNS to destination IP

Example commands

mysqldump --routines -uroot -p database1 > /root/dumps/database1.sql
rsync -aHvx --numeric-ids --progress root@sourceServer:/var/www/website/ /var/www/website/
mysql -uroot -p database1 < /root/dumps/database1.sql