Checklist based on general guide https://github.com/openfoodfoundation/ofn-install/wiki/Migrating-a-Production-Server
Each server may be slightly different, so make sure to update the list as needed.
1. Setting up the new server
config
setup
Enable passthrough on current server to allow new server to generate a certificate:
Then setup new server. Ensure you have the correct secrets (current secrets are usually fine).
ansible-playbook -l be_prod2 -e "@../ofn-secrets/be_prod/secrets.yml" playbooks/
initial migration
ansible-playbook -l be_prod -e rsync_to=be_prod2 playbooks/
Make sure to clear cache so that instance settings are applied:
cd ~/apps/openfoodnetwork/current; bin/rails runner -e production "Rails.cache.clear"
2. Testing
Use a hosts file entry to test new server using the domain name
3. Migration
preparation
switchover: old server
switchover: new server
4. Cleanup (after 48hrs)
Rollback plan
- If an error occurs after DNS change, users may have interacted with the new server (eg made payments).
- if serious, consider putting new server into maintenance mode to avoid further changes, while investigating
- otherwise seek to resolve issue in-place.
- avoid changing DNS back to old server, because it could be missing any new payments.
Checklist based on general guide https://github.com/openfoodfoundation/ofn-install/wiki/Migrating-a-Production-Server
Each server may be slightly different, so make sure to update the list as needed.
1. Setting up the new server
ls /etc/nginx/sites-enabledsystemctl --state=runningconfig
host_vars/x/config.yml, clean up if neededgroup_vars/x.yml, clean up if neededofn-secrets:be_prod/secrets.yml, clean up if neededsetup
Enable passthrough on current server to allow new server to generate a certificate:
ansible-playbook playbooks/letsencrypt_proxy.yml -l be_prod -e "proxy_target=<new_ip>"Then setup new server. Ensure you have the correct secrets (current secrets are usually fine).
ansible-playbook -l be_prod2 -e "@../ofn-secrets/be_prod/secrets.yml" playbooks/setup.ymlprovision.ymldeploy.ymldb_integrations(Permit DB access for n8n, Metabase)initial migration
sudo systemctl stop sidekiq && sudo systemctl disable sidekiqofn-adminandopenfoodnetworkas per guideansible-playbook -l be_prod -e rsync_to=be_prod2 playbooks/db_transfer.yml&&transfer_assets.ymlMake sure to clear cache so that instance settings are applied:
cd ~/apps/openfoodnetwork/current; bin/rails runner -e production "Rails.cache.clear"2. Testing
Use a
hostsfile entry to test new server using the domain namereboot/admin/mail_methods/edit)./admin/terms_of_service_filesnote: check cookies if login won't work
/admin/stripe_connect_settings/edit)3. Migration
preparation
bin/rake db:reset(You will need to confirm. Make sure you're on the new server!)inventory/hostsand ensure provision works (this will update host in.env.production).ansible-playbook playbooks/provision.yml -l be_prodansible-playbook playbooks/deploy.yml -l be_prod -e "git_version=vX.Y.Z"matching version with current prod (you can check this at the bottom of/admin/dashboard).in meta description/admin/general_settings/edit)switchover: old server
ansible-playbook playbooks/maintenance_mode.yml -l be_prodansible-playbook -l be_prod -e rsync_to=be_prod2 playbooks/db_transfer.yml &&ansible-playbook -l be_prod -e rsync_to=be_prod2 playbooks/transfer_assets.yml/var/lib/redis-jobs/dump.rdbto new server (see guidesudo systemctl stop postgresql(ensure other integrations no longer touch it)switchover: new server
sudo systemctl restart puma; sudo systemctl start sidekiq redis-jobscd ~/apps/openfoodnetwork/current; bin/rails runner -e production "Rails.cache.clear"(or migrate redis-cache/dump.rdb also)hostsfile entry to test that there are no alarm bells, eg:~/apps/openfoodnetwork/current/log/production.logandsidekiq.log4. Cleanup (after 48hrs)
Rollback plan