Exporting, importing and backing up your data

In this guide we cover:

Migrate from a VM to Docker

In this guide we'll use [dradispro.old] to refer to the IP address of your existing Dradis VM and [host] to refer to the hostname of your new Docker host.

Prerequisites

First of all, you will need to prepare your new host for deployment.

  1. Navigate to the latest release or click the Download button in the center column of the portal landing page.
  2. Click Download Docker image and download the image. The new image file will be named something like dradis-pro-5.xx.0-assess.tar.gz.
  3. Copy the new image to your host, connect as your user e.g. deployer, and load it:
    scp dradis-pro-5.xx.0-assess.tar.gz deployer@[host]:.
    ssh deployer@[host]
    docker image load < dradis-pro-5.xx.0-assess.tar.gz

Step 1: Migrate the database

  1. Export your database from the existing VM:

    $ ssh dradispro@[dradispro.old] -- 'dp-export-mysql' > dradis-mysql-backup.sql
  2. Open dradis-mysql-backup.sql in a text editor, add the following two lines at the very top of the file, and save:

    CREATE DATABASE IF NOT EXISTS dradis_production;
    USE dradis_production;
  3. Copy the file into the init/ directory on your new Docker host:

    $ scp dradis-mysql-backup.sql deployer@[host]:init/

Your data will be imported automatically into the database container on first startup.

Step 2: Start the Docker containers

  1. Connect to your new host as deployer:

    $ ssh -p 22121 deployer@[host]
  2. Start the stack in the background:

    $ docker compose up -d

Step 3: Update configurations

You'll need to migrate your configuration values from the VM to the new container environment.

  1. Copy the migration script into the app container:

    $ docker cp migrate_configuration.rb app:/dradispro
  2. Run the migration script:

    $ docker exec -i app bundle exec rails runner migrate_configuration.rb

Step 4: Migrate templates, attachments, and more

  1. Copy the dp-import script into the app container:

    $ docker cp pro/dp-import app:/dradispro
  2. Run each of the following import commands in turn:

    $ ssh dradispro@[dradispro.old] 'dp-export-storage' |\
        docker exec -i app /dradispro/dp-import "storage"
    $ ssh dradispro@[dradispro.old] 'dp-export-templates' |\
        docker exec -i app /dradispro/dp-import "templates"
    $ ssh dradispro@[dradispro.old] 'dp-export-attachments' |\
        docker exec -i app /dradispro/dp-import "attachments"

    If you had Gateway installed on your VM, also run:

    $ ssh dradispro@[dradispro.old] 'dp-export-themes' |\
        docker exec -i app /dradispro/dp-import "themes"

    If any users on your instance has custom avatars, also run:

    ssh dradispro@[dradispro.old] 'tar -cf - -C /opt/dradispro/dradispro/shared avatars' |\
        docker exec -i app tar -xpf - -C /dradispro/storage/public

Backing up your data

The backup operation is conceptually the same as the export operation described earlier, the only difference is that instead of piping the export scripts to the import scripts in the new instance we just archive the results.

Run these commands from your local machine:

$ ssh deployer@[dradispro] -- 'docker exec app dp-export-attachments' > dradis-attachments.tar

$ ssh deployer@[dradispro] -- 'docker exec app dp-export-mysql' | gzip > dradis-mysql-backup.sql.gz

$ ssh deployer@[dradispro] -- 'docker exec app dp-export-templates' > dradis-templates.tar

You can script this and combine it with your standard backup software to make sure all your Dradis data is safe.

In addition, you should consider the additional step of encrypting your backups for good measure (something simple like openssl should do the trick):

$ openssl enc -aes-256-cbc -salt -in file.plain -out file.enc

Great job, you reached the end of the guide! Have you read all of them?

Seven Strategies To Differentiate Your Cybersecurity Consultancy

You don’t need to reinvent the wheel to stand out from other cybersecurity consultancies. Often, it's about doing the simple things better, and clearly communicating what sets you apart.

  • Tell your story better
  • Improve your testimonials and case studies
  • Build strategic partnerships

Your email is kept private. We don't do the spam thing.