Files
docker-images/ceph-rbd-backup/script.sh
2026-10-02 23:34:52 +02:00

22 lines
623 B
Bash

#!/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};