Copying instance data and files
Migrating a Canopy instance's data and files from one server to another
NOTE THAT THESE ACTIONS WILL DELETE ALL DATA ON THE TARGET SERVER
Exporting on source server(as root):
Stop Canopy:
systemctl stop canopy canopy-celery
Note for older versions(3.0) of Canopy one would use `supervisord` instead of `systemd`
Create DB dump:
canopy-manage dumpdata --all -o db.json
Archive uploaded files:
tar -zcvf canopy_files.tgz /var/opt/checksec/canopy
Start daemons again if required.
systemctl start canopy canopy-celery
- Copy db.json and canopy_files.tgz to Server B
Importing on target server(as root):
Stop Canopy:
systemctl stop canopy canopy-celery
If database structure is outdated or non-existent then configure a production DB:
canopy-manage setupdb --prod --drop-tables
Delete data in DB:
canopy-manage flush
Remove remaining remnants that are autogenerated:
Note this may delete files in /var/opt/checksec/canopy/ if their respective objects are still in the DB
echo -e 'from django.apps import apps\nfor model in apps.get_models(): model.objects.all().delete()' | SKIP_PRBAC_CHECKS=1 canopy-manage shell
Load db.json:
SKIP_PRBAC_CHECKS=1 canopy-manage loaddata db.json
Extract Canopy files:
tar -xvf canopy_files.tgz -C /
Set ownership of files:
chown -R canopy: /var/opt/checksec/canopy
Start Canopy:
systemctl start canopy canopy-celery