Canopy
Canopy

Copying instance data and files

Migrating from one server to another

Warning

THESE ACTIONS WILL DELETE ALL DATA ON THE TARGET SERVER

Exporting on source server (as root):

  1. Stop Canopy services:

    systemctl stop canopy canopy-celery
    

    Note for older versions (3.0) of Canopy one would use supervisorctl instead of systemctl.

  2. Create a database dump:

    canopy-manage dumpdata --all -o db.json
    
  3. Archive data files:

    tar -zcvf canopy_files.tgz /var/opt/checksec/canopy
    
  4. Start services again if required:

    systemctl start canopy canopy-celery
    
  5. Copy db.json and canopy_files.tgz to target server.

Importing on target server (as root):

  1. Stop Canopy services:

    systemctl stop canopy canopy-celery
    
  2. If database structure is outdated or non-existent then configure a production database:

    canopy-manage setupdb --prod --drop-tables
    
  3. Delete data in database:

    canopy-manage flush
    
  4. Remove remaining remnants that are auto-generated:

    Warning

    This may delete files in /var/opt/checksec/canopy/ if their respective objects are still in the database.

    echo -e 'from django.apps import apps\nfor model in apps.get_models(): model.objects.all().delete()' | SKIP_PRBAC_CHECKS=1 canopy-manage shell
    
  5. Load database dump (db.json):

    SKIP_PRBAC_CHECKS=1 canopy-manage loaddata db.json
    
  6. Extract Canopy data files:

    tar -xvf canopy_files.tgz -C /
    
  7. Set ownership of files:

    chown -R canopy: /var/opt/checksec/canopy
    
  8. Start Canopy services:

    systemctl start canopy canopy-celery