What's the best way to back up and restore CDRouter?

Backing up and restoring your CDRouter system may be done very easily. You can use the backup method of your choice (rsync, tar, gzip, sftp, etc) to simply copy things to a remote system. This article will explain what needs to be backed up as well as some important information about the process.

CDRouter Data Directory

The most important area to back up is CDRouter’s data directory. Depending on how your system was installed, your CDRouter data directory is one of the following locations:

  • /usr/buddyweb - This is the CDRouter data directory used for all versions prior to 10.0
  • /usr/cdrouter-data - This is the CDRouter data directory used by CDRouter 10.0 and later.

If both /usr/buddyweb and /usr/cdrouter-data exist, one will be a symbolic link to the other. Be sure to back up both of the above directories if they exist (to preserve the symbolic link).

Note that the CDRouter data directory is kept separate from all of CDRouter’s installation files (ie. test scripts, executables and other static files). There is no need to back up the installation files, as they are automatically updated whenever you run the CDRouter installer to upgrade, downgrade, or reinstall the CDRouter product.

If there is ever a problem with running CDRouter itself and you suspect that the installation has been corrupted, we recommend that you first try to reinstall CDRouter or upgrade to a different version before trying to restore your CDRouter data directory.

Whether you are upgrading or downgrading CDRouter, the installer will only overwrite the operational data files and leave your CDRouter data intact.

Important: You must stop the CDRouter service before performing any backup or restore operation of the /usr/buddyweb or /usr/cdrouter-data directories. This will stop all CDRouter web interface processes and prevent database files from being corrupted.

Important: The backup/restore method you use must preserve the original file ownership and permissions of all CDRouter data files and directories. In particular, the files and directories under /usr/buddyweb and /usr/cdrouter-data should have root user and group ownership. Additionally, for systems running CDRouter 10.0 or higher, the /usr/buddyweb/data or /usr/cdrouter-data/data trees must have cdrouter user and group ownership. These can be set explicitly if necessary after a restore.

Important: Delete the contents of any existing /usr/buddyweb or /usr/cdrouter-data directories before restoring CDRouter data from a backup archive. This will ensure that your CDRouter directories are restored with only their original contents so that CDRouter will be able to accurately find files referenced in its database.

Using CDRouter’s Backup (and Restore) Tool

A backup and restore tool is provided as part of the CDRouter installation.
This tool may be used to accomplish the requirements specified above to create a ‘good’ backup file. The CDRouter Backup and Restore Tool knowledge base article provides instructions on how to use it.

Other things to back up and restore

In addition to the /usr/buddyweb and /usr/cdrouter-data directories, there may be other things you’ll want to back up. These can be backed up or restored at any time, even while CDRouter is running, and no special steps are necessary.

  • Data is only stored in /usr/cdrouter-data (or /usr/buddyweb) if you perform your testing using CDRouter’s web interface.

However, if you perform any testing by running the cdrouter-cli CLI command directly, CDRouter will not keep track of these test results. In order to keep this information safe, you must manually organize and back up any test results generated by the cdrouter-cli command.

  • If you make use of any custom testpaths, you’ll want to save them off as well. A list of custom testpaths can be found under the main User menu -> System -> Preferences.

  • Finally, any other files or directories you want to preserve should also get backed up.

Alternative Method of Backup and Restore

The CDRouter Backup and Restore Tool provides an easy to create and restore a backup for your CDRouter data. However, the are several other ways to accomplish these tasks. The paragraphs below provide an alternate example using the Linux rsync command.

CDRouter Data Directory Backup Example

The following example will use rsync to create an archive of the /usr/buddyweb and /usr/cdrouter-data directories on a remote host named fileserver. We’ll connect as user and put the archive in /backupdir. Any system should work as long as you can connect to it over the network, you have an account on it, and the system has enough disk space for the archive.

First, stop the CDRouter service.

service cdrouter stop

or

systemctl stop cdrouter

Next, save off the buddyweb and cdrouter-data directories.

cd /usr
rsync -av buddyweb user@fileserver:/backupdir
rsync -av cdrouter-data user@fileserver:/backupdir

Finally, start up the CDRouter service.

service cdrouter start

or

systemctl start cdrouter

CDRouter Data Directory Restore Example

The following example illustrates how to restore CDRouter data with the contents of the backup created in the previous section.

First, stop the CDRouter service.

service cdrouter stop

or

systemctl stop cdrouter

At this point, it’s usually best to delete any existing files in /usr/buddyweb and /usr/cdrouter-data. This will prevent any conflicts between old and new content, particularly database files.

rm -rf /usr/buddyweb/*
rm -rf /usr/cdrouter-data/*

Next, restore the cdrouter-data and buddyweb directories.

rsync -av user@fileserver:/backupdir/buddyweb /usr
rsync -av user@fileserver:/backupdir/cdrouter-data /usr

Run the following commands to reset the ownership, if necessary. Depending on your system and version of CDRouter, not all of these commands are necessary, but running them anyway is fine.

chown -R root:root /usr/buddyweb
chown -R root:root /usr/cdrouter-data
chown -R cdrouter:cdrouter /usr/buddyweb/data
chown -R cdrouter:cdrouter /usr/cdrouter-data/data

Finally, start up the CDRouter service.

service cdrouter start

or

systemctl start cdrouter

Partial Backup and Restore options

CDRouter allows selected test results, packages and config files to be exported as a standalone .gz file. Resources exported in this way can then be reimported into CDRouter as a way to restore items that were inadvertently deleted or modified.

Please see the following Knowledge Base article for detailed instructions on exporting and importing individual CDRouter test results, packages and configurations: