FUll BACKUP
BACKUP
Tạo volume
shell> rbd create rbd/volume01 --size 102400
Check volume sau khi tạo
shell> rbd ls rbd
volume01
Kiểm tra thông tin volume
shell> rbd info rbd/volume01
rbd image 'volume01':
size 100 GiB in 25600 objects
order 22 (4 MiB objects)
snapshot_count: 0
id: 03f2d71efdde65
block_name_prefix: rbd_data.03f2d71efdde65
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
op_features:
flags:
create_timestamp: Sun Jul 27 22:22:37 2025
access_timestamp: Sun Jul 27 22:22:37 2025
modify_timestamp: Sun Jul 27 22:22:37 2025
Xem thông tin dung lượng của image RBD, bao gồm phần đã provisioned (cấp phát) và phần đã thực sự sử dụng trên cluster Ceph
shell> rbd du rbd/volume01
NAME PROVISIONED USED
volume01 100 GiB 0 B
Dùng rbd bench để ghi 50M dữ liệu vào volume
shell> rbd bench rbd/volume01 --io-type write --io-size 4K --io-threads 4 --io-total 50M
bench type write io_size 4096 io_threads 4 bytes 52428800 pattern sequential
SEC OPS OPS/SEC BYTES/SEC
elapsed: 0 ops: 12800 ops/sec: 13793.1 bytes/sec: 54 MiB/s
Xem lại thông tin dung lượng của image RBD
shell> rbd du rbd/volume01
NAME PROVISIONED USED
volume01 100 GiB 64 MiB
Export toàn bộ nội dung image volume01 ra file .img dạng raw, bao gồm cả vùng chưa ghi (full backup)
shell> rbd export rbd/volume01 volume01-full_snap01.img
Exporting image: 100% complete...done.
Xem lại dung lượng của image có 100G bằng với RAW image
shell> ls -lh
total 65M
-rw-r--r-- 1 root root 100G Jul 27 22:23 volume01-full_snap01.img
RESTORE
Bạn không cần tạo image trước — chỉ cần dùng lệnh dưới. Lệnh này dùng để import image từ file .img vào RBD, tạo ra image mới tên volume01-restore với dữ liệu giống bản backup.
shell> rbd import volume01-full_snap01.img rbd/volume01-restore
Importing image: 100% complete...done.
✅ Nếu rbd/volume01-restore chưa tồn tại, Ceph sẽ tự tạo với đúng size. ❌ Nếu nó đã tồn tại → lỗi (17) File exists
Xem lại dung lượng của image có 100G bằng với RAW image
shell> rbd ls rbd
volume01
volume01-restore
Xem thông tin image sau khi import
shell> rbd info rbd/volume01-restore
rbd image 'volume01-restore':
size 100 GiB in 25600 objects
order 22 (4 MiB objects)
snapshot_count: 0
id: d55c4045d057a0
block_name_prefix: rbd_data.d55c4045d057a0
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
op_features:
flags:
create_timestamp: Sun Jul 27 22:24:38 2025
access_timestamp: Sun Jul 27 22:24:38 2025
modify_timestamp: Sun Jul 27 22:26:07 2025
Xem lại dung lượng của image có 100G bằng với RAW image
shell> rbd du rbd/volume01-restore
NAME PROVISIONED USED
volume01-restore 100 GiB 64 MiB
INCREMENTAL BACKUP
BACKUP
Tạo volume
shell> rbd create rbd/volume01 --size 102400
Check volume sau khi tạo
shell> rbd ls rbd
volume01
Kiểm tra thông tin volume
shell> rbd info rbd/volume01
rbd image 'volume01':
size 100 GiB in 25600 objects
order 22 (4 MiB objects)
snapshot_count: 0
id: f85f21d81114e9
block_name_prefix: rbd_data.f85f21d81114e9
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
op_features:
flags:
create_timestamp: Sun Jul 27 22:28:09 2025
access_timestamp: Sun Jul 27 22:28:09 2025
modify_timestamp: Sun Jul 27 22:28:09 2025
Xem thông tin dung lượng của image RBD, bao gồm phần đã provisioned (cấp phát) và phần đã thực sự sử dụng trên cluster Ceph
shell> rbd du rbd/volume01
NAME PROVISIONED USED
volume01 100 GiB 0 B
Dùng rbd bench để ghi 50M dữ liệu vào volume
shell> rbd bench rbd/volume01 --io-type write --io-size 4K --io-threads 4 --io-total 50MB
bench type write io_size 4096 io_threads 4 bytes 52428800 pattern sequential
SEC OPS OPS/SEC BYTES/SEC
elapsed: 1 ops: 12800 ops/sec: 12121.2 bytes/sec: 47 MiB/s
Tạo snap đầu tiên để backup full dạng incremental
shell> rbd snap create rbd/volume01@snap-01
Creating snap: 100% complete...done.
Xem lại thông tin dung lượng của image RBD
shell> rbd du rbd/volume01
NAME PROVISIONED USED
volume01@snap-01 100 GiB 64 MiB
volume01 100 GiB 0 B
<TOTAL> 100 GiB 64 MiB
Xem danh sách snap
shell> rbd snap list rbd/volume01
SNAPID NAME SIZE PROTECTED TIMESTAMP
44 snap-01 100 GiB Sun Jul 27 22:28:38 2025
Tiến hành export dữ liệu tại snapshot snap-01 dưới dạng file .diff, chỉ chứa các block có dữ liệu (không xuất toàn bộ image)
shell> rbd export-diff rbd/volume01@snap-01 volume01.full.diff
Exporting image: 100% complete...done.
File backup sau khi export có dung lượng tương đương với mức sử dụng
shell> ls -lh
total 51M
-rw-r--r-- 1 root root 51M Jul 27 22:28 volume01.full.diff
Dùng rbd bench để ghi thêm 25M dữ liệu vào volume
shell> rbd bench rbd/volume01 --io-type write --io-size 4K --io-threads 4 --io-total 25MB
bench type write io_size 4096 io_threads 4 bytes 26214400 pattern sequential
SEC OPS OPS/SEC BYTES/SEC
elapsed: 0 ops: 6400 ops/sec: 14814.8 bytes/sec: 58 MiB/s
Tạo snap thứ 2
shell> rbd snap create rbd/volume01@snap-02
Creating snap: 100% complete...done.
Xem lại thông tin dung lượng của image RBD
shell> rbd du rbd/volume01
NAME PROVISIONED USED
volume01@snap-01 100 GiB 64 MiB
volume01@snap-02 100 GiB 32 MiB
volume01 100 GiB 0 B
<TOTAL> 100 GiB 96 MiB
Xem lại danh sách snap
shell> rbd snap list rbd/volume01
SNAPID NAME SIZE PROTECTED TIMESTAMP
44 snap-01 100 GiB Sun Jul 27 22:28:38 2025
45 snap-02 100 GiB Sun Jul 27 22:30:45 2025
Export các thay đổi giữa snapshot snap-01 và snap-02 của image volume01 vào file incremental .diff
shell> rbd export-diff --from-snap snap-01 rbd/volume01@snap-02 volume01.inc02.diff
Exporting image: 100% complete...done.
File backup sau khi export có dung lượng tương đương với mức sử dụng là 25mb
shell> ls -lh
total 76M
-rw-r--r-- 1 root root 51M Jul 27 22:28 volume01.full.diff
-rw-r--r-- 1 root root 26M Jul 27 22:31 volume01.inc02.diff
RESTORE
Bạn cần tạo image trống bằng đúng kích thước image gốc:
rbd create rbd/volume01-restore --size 102400
Xem lại danh sách volume
shell> rbd ls rbd
volume01
volume01-restore
Kiểm tra thông tin volume
shell> rbd info rbd/volume01-restore
rbd image 'volume01-restore':
size 100 GiB in 25600 objects
order 22 (4 MiB objects)
snapshot_count: 0
id: f86dfdf8457cb2
block_name_prefix: rbd_data.f86dfdf8457cb2
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
op_features:
flags:
create_timestamp: Sun Jul 27 22:33:37 2025
access_timestamp: Sun Jul 27 22:33:37 2025
modify_timestamp: Sun Jul 27 22:33:37 2025
Xem lại thông tin dung lượng của image RBD
shell> rbd du rbd/volume01-restore
NAME PROVISIONED USED
volume01-restore 100 GiB 0 B
Import bản full diff trước, file .full.diff chứa snapshot đầu tiên. Lệnh này sẽ phục hồi trạng thái của snapshot gốc.
shell> rbd import-diff volume01.full.diff rbd/volume01-restore
Importing image diff: 100% complete...done.
Xem lại thông tin dung lượng của image RBD
shell> rbd du rbd/volume01-restore
NAME PROVISIONED USED
volume01-restore@snap-01 100 GiB 64 MiB
volume01-restore 100 GiB 0 B
<TOTAL> 100 GiB 64 MiB
Import incremental diff tiếp theo. File này chứa các thay đổi giữa snapshot-01 và snapshot-02
shell> rbd import-diff volume01.inc02.diff rbd/volume01-restore
Importing image diff: 100% complete...done.
Xem lại thông tin dung lượng của image RBD
shell> rbd du rbd/volume01-restore
NAME PROVISIONED USED
volume01-restore@snap-01 100 GiB 64 MiB
volume01-restore@snap-02 100 GiB 32 MiB
volume01-restore 100 GiB 0 B
<TOTAL> 100 GiB 96 MiB
Xem danh sách snap
rbd snap list rbd/volume01-restore
SNAPID NAME SIZE PROTECTED TIMESTAMP
46 snap-01 100 GiB Sun Jul 27 22:38:22 2025
47 snap-02 100 GiB Sun Jul 27 22:39:47 2025
Kiểm tra image đã phục hồi.
shell> rbd info rbd/volume01-restore
rbd image 'volume01-restore':
size 100 GiB in 25600 objects
order 22 (4 MiB objects)
snapshot_count: 2
id: f86dfdf8457cb2
block_name_prefix: rbd_data.f86dfdf8457cb2
format: 2
features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
op_features:
flags:
create_timestamp: Sun Jul 27 22:33:37 2025
access_timestamp: Sun Jul 27 22:33:37 2025
modify_timestamp: Sun Jul 27 22:39:47 2025
CLEAR VOLUME
Xóa toàn bộ snapshot của volume01 (snap purge), sau đó xóa luôn image volume01 khỏi pool (rbd rm).
shell> rbd snap purge rbd/volume01 && rbd rm rbd/volume01
Removing image: 100% complete...done.
Tương tự cho volume01-restore
shell> rbd snap purge rbd/volume01-restore && rbd rm rbd/volume01-restore
Removing image: 100% complete...done.