How to move the data index to another location.


What is the data index?

The data index in CubeBackup acts as a cache to speed up the backup process. It contains a part of the metadata for your backup, including SQLite database files, configuration files, and other information used in the backup process. For more information about the data index, please refer to What is the data index and why is it needed?

In some scenarios, you may need to move the data index to a new place. For example:

  • The partition where the data index is stored is nearly full. You need to move the data index to a larger partition.

    If you run out of space on your CubeBackup EC2 instance - perhaps because the data index has grown beyond your initial parameters - it is easy to extend the volume size without detaching the volume or migrating the data index. For detailed instructions, you can follow the steps in Method 3.

  • In the initial configuration, you placed the data index on an HDD or network storage, which slows down your backups. Now you decided to move the data index to an SSD.


Fortunately, there are simple methods to move the data index to a new location:

Method 1: Move the data index to a new directory.

  1. In the CubeBackup web console, stop the current backup job if it is running.

  2. Stop the CubeBackup service.

    On Linux, run this command in the bash shell:

    sudo /opt/cubebackup/bin/cbsrv stop

    On Windows, enter services.msc in the command line, then in the Services list that pops up, right-click the CubeBackup entry, and select Stop.

  3. Create a new directory in the new storage location and copy everything from the original data index directory to this new location.

    On Linux, please also make sure to change the owner of the target directory (e.g. /var/cubebackup_index) to cbuser :

    sudo chown cbuser:cbuser /var/cubebackup_index
  4. Modify the <cubebackup installation directory>/db/storage.json file, by changing the value of “IndexPath” to the new directory.

    Tips:

    • On Windows, CubeBackup is installed in the “C:\Program Files\CubeBackup4” directory by default.
      On Linux, CubeBackup is installed in the “/opt/cubebackup” directory by default.

    • On Windows, please use double backslashes to separate the directory path. For example:

      "IndexPath": "C:\\backups\\cube_index"
  5. Restart the CubeBackup service.

    • On Linux, run this command in the bash shell:

      sudo /opt/cubebackup/bin/cbsrv start
    • On Windows, enter services.msc in the command line, then in the Services list that pops up, right-click the CubeBackup entry, and select Start.

Method 2: Regenerate the data index in a new directory.

  1. In the CubeBackup web console, stop the current backup job if one is running.

  2. Stop the CubeBackup service.

    On Linux, run this command in the bash shell:

    sudo /opt/cubebackup/bin/cbsrv stop

    On Windows, enter services.msc in the command line, then in the Services list that pops up, right-click the CubeBackup entry, and select Stop.

  3. Merge the data index cache to backup storage using the command:

    cbackup syncDataIndex

    NOTE: This command needs to be run using a special account.

    • On Windows, by default, the cbackup.exe command is located in “C:\Program Files\CubeBackup4\bin” directory. You need to run the cbackup syncDataIndex command as an administrator.
    • On Linux, this command must be run by the user cbuser.

      sudo -u cbuser  /opt/cubebackup/bin/cbackup syncDataIndex
  4. Create a new directory on the new storage.

    On Linux, please also make sure to change the owner of the target directory (e.g. /var/cubebackup_index) to cbuser :

    sudo chown cbuser:cbuser /var/cubebackup_index
  5. then modify the <cubebackup installation directory>/db/storage.json file by changing the value of “IndexPath” to the new directory.

    Tips:

    • On Windows, CubeBackup is installed in the “C:\Program Files\CubeBackup4” directory by default.
      On Linux, CubeBackup is installed in the “/opt/cubebackup” directory by default.

    • On Windows, please use double backslashes to separate the directory path. For example:

      "IndexPath": "C:\\backups\\cube_index"
  6. Restart the CubeBackup service.

    On Linux, run this command in the bash shell:

    sudo /opt/cubebackup/bin/cbsrv start

    On Windows, enter services.msc in the command line, then in the Services list that pops up, right-click the CubeBackup entry, and select Start.

  7. CubeBackup will automatically regenerate the data index in the new directory.

Method 3: Extend the volume size on an EC2 instance

For an EC2 instance, please follow the instructions below to extend the partition size of your EC2 instance:

  1. First extend the volume size in AWS console:
    • In the CubeBackup console, click Stop backup to if there is a current backup process.
    • Login to your AWS console and then select the EC2 instance on which CubeBackup is running.
    • In the Storage tab, click the Volume ID -> Actions -> Modify Volume and resize the volume to a larger size.
  2. Then you need to extend the partition itself:

    • SSH to the EC2 instance.
    • Type the following command to list the block devices:

      lsblk
    • You should see something similar to the example below. The size of the root volume reflects the resized space (20GB) and the size of the partition reflects the original size (8GB), which must be extended before you can extend the file system. partition size

    • To do so, type the following command:

      sudo growpart /dev/xvda 1

      Carefully note that there is a space between the device name and partition number.

    • You can use the lsblk command again to check that the partition reflects the increased volume size. changed partition size

  3. Last but not least, you need to extend the filesystem itself:

    • Use the following command for ext2,ext3 or ext4 file systems:

      sudo resize2fs /dev/xvda1
    • For an XFS file system, use the command below:

      sudo xfs_growfs /dev/xvda1
    • You can check the extended filesystem with:

      df -h
  4. If everything goes smoothly, you will see that the partition size has changed in the CubeBackup web console. extended file system