This is an internal documentation. There is a good chance you’re looking for something else. See Disclaimer.

Move Database between Servers

Checklist for moving DBs between clusters.

Pre-Move

  • (prod-only) Announce downtime ~one week in advance.

  • Check disk space:

    $ tco db-size ${installation}
    $ ssh ${target_server} df -h /var/lib/postgresql/
    
  • (unannounced / test-only) check for users:

    $ tco sessions ${installation}
    

    If anyone is using the installation, consider postponing the move. Use tco sessions -v to see additional details.

Move

  • Update db_server in config.yml and create new DBs and user:

    ansible-playbook playbook.yml -l ${INSTALLATION} -t postgres
  • Start maintenance page:

    ./mntnc –auto-scale start

    This will stop the installation.

    See Maintenance Page

  • (prod-only) Initialize history DB:

    copy_history_db --init-only ${source_host} ${source_db} ${target_host} ${target_db}
    
  • Move main DB:

    copy_db <source_host> <source_db> <target_host> <target_db>
    
  • Rename DB on old server:

    $ tco db -t postgres ${installation}
    $ ALTER DATABASE nice_<installation> RENAME TO nice_<installation>_moved;
    

    Note

    Safety mesure to ensure the old DB cannot be written to accidentally.

  • Update OpenShift config:

    $ ansible-playbook playbook.yml --skip-tags ingress
    

    Note

    Skipping ingress to prevent reverting changes made by ./mntnc.

  • Verify deployment succeeded:

    $ oc project nice-${installation}
    $ oc get pods
    
  • Stop maintenance page:

    ./mntnc --auto-scale stop
    
  • Verify installation is back online

Post-Move

  • (prod-only) On the next day complete move history DB:

    copy_history_db --skip-init ${source_host} ${source_db} ${target_host} ${target_db}
    

    Note

    Do not do this overnight as we run into issues before. Do not bother copying DB for test systems unless explicitly requested.

  • Remove old DBs four days later:

    tco dbs unused --ask-delete