After completing this section, you should be able to export an RBD image from the cluster to an external file and import it into another cluster.
The RBD export and import mechanism allows you to maintain operational copies of RBD images that are fully functional and accessible, either within the same cluster or by using a separate cluster. You can use these copies for a variety of use cases, including:
Testing new versions using realistic volumes of data
Running quality assurance processes using realistic volumes of data
Implementing business continuity scenarios
Decoupling backup processes from the production block devices
Red Hat Ceph Storage provides the rbd export command to export an RBD image to a file.
This command exports an RBD image or an RBD image snapshot to the specified destination file.
The rbd export command has the following syntax:
rbd export [--export-format {1|2}] (image-spec | snap-spec) [dest-path]The --export-format option specifies the format of the exported data, allowing you to convert earlier RBD format 1 images to newer, format 2 images.
The following example exports an RBD image called test to the /tmp/test.dat file.
[ceph: root@node /]# rbd export rbd/test /tmp/test.datRed Hat Ceph Storage provides the rbd import command to import an RBD image from a file .
The command creates a new image and imports the data from the specified source path.
The rbd import command has the following syntax:
rbd import [--export-format {1|2}] [--image-format format-id] [--object-size size-in-B/K/M] [--stripe-unit size-in-B/K/M --stripe-count num] [--image-feature feature-name]... [--image-shared] src-path [image-spec]The --export-format option specifies the data format of the data to be imported.
When importing format 2 exported data, use the --stripe-unit, --stripe-count, --object-size, and --image-feature options to create the new RBD format 2 image.
The --export-format parameter value must match for the related rbd export and the rbd import commands.
Red Hat Ceph Storage provides the rbd export-diff and the rbd import-diff commands to export and import changes made between two points in time on an RBD image.
The syntax is the same as for the rbd export and rbd import commands.
The endpoint in time can be:
The current content of an RBD image, such as poolname/imagename.
A snapshot of an RBD image, such as poolname/imagename@snapname.
The start time can be:
The creation date and time of the RBD image. For example, without using the --from-snap option.
A snapshot of an RBD image, such as is obtained by using the --from-snap snapname option.
If you specify a start point snapshot, the command exports the changes after you created that snapshot. If you do not specify a snapshot, the command exports all changes since the creation of the RBD image, which is the same as a regular RBD image export operation.
The import-diff operation performs the following validity checks:
If the export-diff is relative to a start snapshot, this snapshot must also exist in the target RBD image.
If the export-diff is performed specifying an end snapshot, the same snapshot name is created in the target RBD image after the data is imported.
Specifying the dash (-) character as the target file of an export operation causes the output to go to standard output (stdout).
You can also use the dash character (-) to specify either stdout or standard input (stdin) as the export target or import source.
You can pipe two commands into a single command.
[ceph: root@node /]# rbd export rbd/img1 - | rbd import - bup/img1The rbd merge-diff command merges the output of two continuous incremental rbd export-diff image operations into one single target path.
The command can only process two incremental paths at one time.
[ceph: root@node /]# rbd merge-diff first second mergedTo merge more than two continuous incremental paths in a single command, pipe one rbd export-diff output to another rbd export-diff command.
Use the dash character (-) as the target in the command before the pipe, and as the source in the command after the pipe.
For example, you can merge three incremental diffs into a single merged target on one command line.
The snapshot end time of the earlier export-diff command must be equal to the snapshot start time of the later export-diff command.
[ceph: root@node /]# rbd merge-diff first second - | rbd merge-diff - third merged