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.

Step 0: Prepare your host

First of all, you will need to prepare your new host for deployment. On the host where you are going to deploy your Docker instance, before deploying it, create a directory called init.

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: Deploy the Docker containers

This step is the same as deploying a fresh, blank Dradis Docker instance. The only difference is that with your .sql file in the init folder, your instance will be created with the data migrated from your VM instance.

curl -fsSL https://get.dradis.com | /bin/bash

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

Loading form...

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