Skip to content

How to migrate a server

Matthew Landauer edited this page Jun 21, 2014 · 7 revisions

Some initial preparation

  • Drop DNS TTL down to 300
  • Wait
  • Drop DNS TTL down to 60

On source server

  • Clear out some old backups in /backups to make room on disk (if necessary)
  • Put discourse into read-only mode
  • Write down discourse S3 credentials
  • Do a manual backup of discourse
  • Put first server into read-only maintenance mode
  • Wait for background jobs to finish (or kill them if they're taking a long time)
  • service morph-worker stop
  • sudo su - deploy; cd /var/www/current; bundle exec rake app:backup RAILS_ENV=production
  • Wait about 10 minutes

On destination server

  • rsync root@[ip of source server]:/var/www/current/db/backups/morph_backup.tar . --progress
  • service morph-worker stop
  • service redis stop
  • sudo su - deploy; cd /var/www/current; bundle exec rake app:restore RAILS_ENV=production
  • Wait about 10 minutes
  • service redis start
  • service morph-worker start
  • Check ownership on sqlite databases (they're probably going to be wrong)

On local machine (for testing)

  • Edit /etc/hosts to add
[ip address of destination server]     morph.io
[ip address of destination server]     faye.morph.io
[ip address of destination server]     discuss.morph.io
  • Switch off read-only mode on destination server
  • Test that things work as expected by clicking around and running a scraper
  • Fill in S3 credentials for discourse from earlier
  • Do restore of discourse from backup
  • Test some more

On DNS:

  • Switch over to new ip address

Final updates:

  • Activate cronjobs on new server (probably just provision with ansible)
  • Switch off old server when everything is good
Clone this wiki locally