Exporting, importing and backing up your data

There are a number of migration scripts that let you export, import and backup all your data easily.

In this guide we cover:

Migrate to a new OVA

Step 0: Checking your current OVA version

If you're unsure on what OVA version you are in right now, visit your instance's CIC page found on the /setup page in your browser. You will also see the End Of Support date for the OVA - we support OVAs built on the current and previous versions of Debian.

You can also check the OVA version by running the following in the console:

$ cat /opt/dradispro/ova_version

Note: If your CIC setup page doesn't have a Versions section or the ova_version file does not exist on your instance, then you are running on an older OVA (< v3.0.0) and it's time to migrate!

Step 1: Launch a new instance

Follow the instructions in the Deploying Dradis Pro step by step guide to launch a new instance of Dradis and use your existing license key to activate it when prompted. Yes, you can have >1 instance running with the same license key at the same time for situations just like this!

Step 2: Exporting and importing your data

Dradis provides a set of scripts to make exporting all your data easily. The export scripts can be used to move your data from an old install to a newer one or to just backup your data.

You can find the scripts referenced in this guide under: /opt/dradispro/bin/

In this guide we'll use [dradispro.old] to refer to the IP address of the original Dradis instance containing the data you want to export / backup and [dradispro.new] to refer to the IP address of a new and fresh install where the data will end up being imported.

Run these commands from your local machine (note that each command can be run in a single line, although we're breaking them up in two):

$ ssh dradispro@[dradispro.old] -- 'dp-export-attachments' |\
    ssh dradispro@[dradispro.new] -- 'dp-import-attachments'

$ ssh dradispro@[dradispro.old] -- 'dp-export-mysql' |\
    ssh dradispro@[dradispro.new] -- 'dp-import-mysql'

$ ssh dradispro@[dradispro.old] -- 'dp-export-templates' |\
    ssh dradispro@[dradispro.new] -- 'dp-import-templates'

From our local machine or laptop we are connecting to [dradispro.old] running the export script and then piping the result to the import script running in [dradispro.new].

After piping, make sure to migrate the database:

Run the following in the command line of [dradispro.new] as dradispro:

$ cd /opt/dradispro/dradispro/current/
$ RAILS_ENV=production bundle exec rails db:migrate
$ god restart dradispro-puma
$ god restart dradispro-resque-1

Too much piping?

If this is a bit too much magic for you, you can break each of the steps in two: export data and dump into an intermediate file in your laptop and then pipe that file into the new install. For example:

$ ssh dradispro@[dradispro.old] -- 'dp-export-attachments' > dradis-attachments.tar

$ cat dradis-attachments.tar | ssh dradispro@[dradispro.new] -- 'dp-import-attachments'
$ ssh dradispro@[dradispro.old] -- 'dp-export-mysql' > dradis-mysql-backup.sql

$ cat dradis-mysql-backup.sql | ssh dradispro@[dradispro.new] -- 'dp-import-mysql'
$ ssh dradispro@[dradispro.old] -- 'dp-export-templates' > dradis-templates.tar

$ cat dradis-templates.tar | ssh dradispro@[dradispro.new] -- 'dp-import-templates'

Again, after exporting and importing, make sure to migrate the database:

Run the following in the command line of [dradispro.new] as dradispro:

$ cd /opt/dradispro/dradispro/current/
$ RAILS_ENV=production bundle exec rails db:migrate
$ god restart dradispro-puma
$ god restart dradispro-resque-1

(Optional) Step 3: Update attachment urls

If you are migrating from an instance with Dradis Pro version lower (<) than 3.0.0 to an instance with version greater or equal to (>=) 3.0.0, most paths on the app have changed.

This can affect paths to attachments you could have inserted in your issues, notes, evidence, etc...

If that is your case and you want to update those paths, grab this script, scp it in your new instance /tmp folder, and execute it like this:

RAILS_ENV=production bin/rails runner /tmp/update_attachment_paths_to_v3.rb

(Optional) Step 4: Migrating your premium add-ons

Do you have an add-on like Azure Authentication, LDAP, Okta, SAML, or a custom add-on installed on [dradispro.old]? You'll want to make sure to migrate those over to your new instance!

  1. Copy the file /opt/dradispro/dradispro/shared/addons/Gemfile.plugins from [dradispro.old] to [dradispro.new].

  2. Open the file and confirm that you have the latest versions of the gems in that file. The add-on version should match the Dradis version (e.g. Dradis v3.0.0 needs dradispro-ldap-3.0.0.gem)

    Need an updated add-on? Contact our support team and we'll get you the files that you need!

  3. In [dradispro.new], scp the new gems to the /opt/dradispro/dradispro/shared/addons/cache directory then update the Gemfile.plugins file with the right version number of the gems.

  4. Copy subfolders in the /opt/dradispro/dradispro/shared/addons/ folder from [dradispro.old] to [dradispro.new] by running the following commands on [dradispro.old]:

    $ cd /opt/dradispro/dradispro/shared/
    $ scp -r /opt/dradispro/dradispro/shared/addons/config dradispro@[dradispro.new]:/opt/dradispro/dradispro/shared/addons 
    $ scp -r /opt/dradispro/dradispro/shared/addons/initializers dradispro@[dradispro.new]:/opt/dradispro/dradispro/shared/addons 
  5. Symlink the add-on files by running these commands on [dradispro.new]:

    $ ln -s /opt/dradispro/dradispro/shared/addons/Gemfile.plugins /opt/dradispro/dradispro/current
    $ ln -s /opt/dradispro/dradispro/shared/addons/cache/* /opt/dradispro/dradispro/current/vendor/cache
    $ ln -s /opt/dradispro/dradispro/shared/addons/config/* /opt/dradispro/dradispro/current/config
    $ ln -s /opt/dradispro/dradispro/shared/addons/initializers/* /opt/dradispro/dradispro/current/config/initializers
  6. Install the add-ons by running the following commands on [dradispro.new]:

    $ cd /opt/dradispro/dradispro/current/
    $ RAILS_ENV=production bundle install --local --without development test
    $ RAILS_ENV=production bundle exec rails assets:precompile
    $ RAILS_ENV=production bundle exec rails db:migrate
    $ god restart dradispro-puma
    $ god restart dradispro-resque-1

(Optional) Step 5: Custom Add-ons/Patches

Local changes will be overwritten during the migration. If you made any local changes to [dradispro.old], make sure to re-apply them to [dradispro.new].

(Optional) Step 6: Custom Uploaded Avatars

If your users have uploaded custom avatars, you can migrate them to the new instance by simply copying over the image files found in /opt/dradispro/dradispro/shared/avatars. Run this command on [dradispro.old]:

$ scp -r /opt/dradispro/dradispro/shared/avatars dradispro@[dradispro.new]:/opt/dradispro/dradispro/shared/

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 VM we just archive the results.

Run these commands from your local machine:

$ ssh dradispro@[dradispro] -- 'dp-export-attachments' > dradis-attachments.tar

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

$ ssh dradispro@[dradispro] -- '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?

Last updated by Christoffer Bjørk Pedersen on 2024-11-21

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.