Skip to content

Commit

Permalink
add support for ceph devices
Browse files Browse the repository at this point in the history
  • Loading branch information
abbbi committed Oct 23, 2024
1 parent 910ae45 commit d0f9671
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,17 @@ the created target images, but may slow down the backup operation.
qmpbackup --socket /path/to/socket info --show blockdev
```

## Including raw devices
## Including raw devices (lvm, zfs, ceph)

Attached raw devices (format: raw) do not support incremental backup. The
only way to create backups for these devices is to create a complete full
backup.
or copy backup.

By default `qmpbackup` will ignore such devices, but you can use the
`--include-raw` option to create a backup for those devices too.

Of course, if you create an incremental backup for these devices, the
complete image will be backed up.
Of course, if you create an incremental backup for these devices, the complete
image will be backed up.

### List existing bitmaps

Expand Down
4 changes: 4 additions & 0 deletions libqmpbackup/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def save_info(backupdir, blockdev):
for dev in blockdev:
infofile = os.path.join(backupdir, f"{os.path.basename(dev.filename)}.config")

if dev.driver == "rbd":
log.info("Skip saving image information for RBD device: [%s]", dev.filename)
continue

info = get_info(dev.filename)
try:
with open(infofile, "wb+") as info_file:
Expand Down
22 changes: 16 additions & 6 deletions libqmpbackup/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
the LICENSE file in the top-level directory.
"""

import os
import json
import logging
from dataclasses import dataclass
Expand All @@ -29,6 +30,7 @@ class BlockDev:
has_bitmap: bool
bitmaps: list
virtual_size: int
driver: str


def get_block_devices(blockinfo, argv, excluded_disks, included_disks, uuid):
Expand All @@ -40,6 +42,7 @@ def get_block_devices(blockinfo, argv, excluded_disks, included_disks, uuid):
bitmaps = None
has_bitmap = False
backing_image = False
driver = None
if "inserted" not in device:
log.debug("Ignoring non-inserted device: %s", device)
continue
Expand Down Expand Up @@ -87,13 +90,19 @@ def get_block_devices(blockinfo, argv, excluded_disks, included_disks, uuid):
try:
encoded_name = json.loads(filename[5:])
try:
filename = encoded_name["file"]["next"]["filename"]
driver = encoded_name["file"]["driver"]
if driver == "rbd":
log.info("Ceph device found, using image name")
filename = encoded_name["file"]["image"]
except KeyError:
log.warning(
"Json encoded setting found but no filename property set for device: [%s]",
device["device"],
)
continue
try:
filename = encoded_name["file"]["next"]["filename"]
except KeyError:
log.warning(
"Json encoded setting found but no filename property set for device: [%s]",
device["device"],
)
continue
except json.decoder.JSONDecodeError as errmsg:
log.warning(
"Unable to decode filename json for device [%s]: %s",
Expand Down Expand Up @@ -128,6 +137,7 @@ def get_block_devices(blockinfo, argv, excluded_disks, included_disks, uuid):
has_bitmap,
bitmaps,
inserted["image"]["virtual-size"],
driver,
)
)

Expand Down

0 comments on commit d0f9671

Please sign in to comment.