diff --git a/ceph-rbd-backup/Dockerfile b/ceph-rbd-backup/Dockerfile new file mode 100644 index 0000000..3b65f85 --- /dev/null +++ b/ceph-rbd-backup/Dockerfile @@ -0,0 +1,5 @@ +FROM quay.io/ceph/ceph:v20.2 + +COPY script.sh /script.sh + +ENTRYPOINT ["/bin/bash", "/script.sh"] diff --git a/ceph-rbd-backup/README.md b/ceph-rbd-backup/README.md new file mode 100644 index 0000000..114ae59 --- /dev/null +++ b/ceph-rbd-backup/README.md @@ -0,0 +1,10 @@ +# Ceph-RBD-backup + +## Environment Variables +| Name | Default | Description | +|---|---|---| +| CEPH_USERNAME | - | TODO | +| RBD_POOL | - | TODO | +| RBD_IMAGE_ID | - | TODO | +| SNAPSHOT_ID | - | TODO | +| OUTPUT_FILE | - | TODO | diff --git a/ceph-rbd-backup/script.sh b/ceph-rbd-backup/script.sh new file mode 100644 index 0000000..ccd6533 --- /dev/null +++ b/ceph-rbd-backup/script.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -euo pipefail + +CEPH_USERNAME="${CEPH_USERNAME:-}" +RBD_POOL="${RBD_POOL:-}" +RBD_IMAGE_ID="${RBD_IMAGE_ID:-}" +SNAPSHOT_ID="${SNAPSHOT_ID:-}" +OUTPUT_FILE="${OUTPUT_FILE:-}" + +# Create the snapshot +rbd --name ${CEPH_USERNAME} snap create ${RBD_POOL}/${RBD_IMAGE_ID}@${SNAPSHOT_ID}; + +# Export the snapshot to a file +rbd --name ${CEPH_USERNAME} export --export-format 2 ${RBD_POOL}/${RBD_IMAGE_ID}@${SNAPSHOT_ID} - | zstd -T1 -3 ${OUTPUT_FILE}; +touch ${OUTPUT_FILE}.done; + +ls -al ${OUTPUT_FILE}; + +# Remove the snapshot again +rbd --name ${CEPH_USERNAME} snap rm ${RBD_POOL}/${RBD_IMAGE_ID}@${SNAPSHOT_ID};