Bobcares

CEPH proxmox backup

by | Jan 26, 2023

Wondering how to perform CEPH proxmox backup? Our proxmox Support team is here to lend a hand with your queries and issues.

CEPH proxmox backup

RBD (RADOS Block Device) volumes can be exported using RBD Snapshots and exports. Once we use Snapshots, we can also run differential exports, so have differential backups from Ceph.

When providing Proxmox with Ceph RBD, it will create a RBD volume for each VM or CT.

CephFS different and are out of the scope. In case you would be interested in creating snapshots on CephFS, just create named subfolder of the .snap magical folder. This will give you a CephFS snapshot, and can be used anywhere in the directory hierarchy. Here is an example I use for some part of CephFS backups in a script:

mkdir /mnt/cephfs/docker/volumes/.snap/$(date +%Y%m%d-%Hh%M)

List rbd pools

root@pve1:~# ceph osd lspools 
1 device_health_metrics
2 cephfs_data
3 cephfs_metadata
4 cephblock

The first pool (device_health_metrics) is for ceph internals. The pools 2 ans 3 are for cephfs. So only the pool 4 interrests us.

List volumes in a rbd pool

root@pve1:~# rbd ls cephblock
vm-101-disk-0
vm-105-disk-0
vm-134-disk-0
vm-139-disk-0

Take a snapshot

rbd snap create {pool-name}/{image-name}@{snap-name}

So in our case:

root@pve1:~# rbd snap create cephblock/vm-139-disk-0@$(date +%Y%m%d-%Hh%M)                        
Creating snap: 100% complete...done.

List the snapshots

root@pve1:~# rbd snap ls cephblock/vm-139-disk-0
SNAPID  NAME            SIZE    PROTECTED  TIMESTAMP                
   46  20220123-17h43  15 GiB             Sun Jan 23 17:43:19 2022

Export the snapshot

root@pve1:~# rbd export cephblock/vm-139-disk-0@20220123-17h43 /tmp/vm-139-disk-0_20220123-17h43
Exporting image: 100% complete...done.
root@pve1:~# ls -lh /tmp/vm-139-disk-0_20220123-17h43
-rw-r--r-- 1 root root 15G 23 jan 18:05 /tmp/vm-139-disk-0_20220123-17h43

It’s possible to extract and compress in a single operation. Here is another example (Thanks Andrii):

rbd export cephblock/vm-101-disk-0@akira_2022-05-25T21:47Z - | nice xz -z8 -T4 > /tmp/vm-101-disk-0_akira_2022-05-25T21:47Z_FULL-RBD-EXPORT.xz

Take another subsequent snapshot

In order to take an incremental backup, we must take a new snapshot.

root@pve1:~# rbd snap create cephblock/vm-139-disk-0@$(date +%Y%m%d-%Hh%M)  
Creating snap: 100% complete...done.
root@pve1:~# rbd snap ls cephblock/vm-139-disk-0
SNAPID  NAME            SIZE    PROTECTED  TIMESTAMP                
   46  20220123-17h43  15 GiB             Sun Jan 23 17:43:19 2022
   47  20220123-22h49  15 GiB             Sun Jan 23 22:49:34 2022

Export the difference between the 2 snapshots

root@pve1:~# rbd export-diff --from-snap 20220123-17h43 cephblock/vm-139-disk-0@20220123-22h49 /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49
root@pve1:~# rbd export-diff --from-snap 20220123-17h43 cephblock/vm-139-disk-0@20220123-22h49 /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49
Exporting image: 100% complete...done.
root@pve1:~# ls -lh /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49
-rw-r--r-- 1 root root 34M 23 jan 22:58 /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49
root@pve1:~# time nice xz -z -T4 /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49  

real    0m2,916s
user    0m4,460s
sys     0m0,095s
root@pve1:~# ls -lh /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49*              
-rw-r--r-- 1 root root 1,4M 23 jan 22:58 /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49.xz

File format

File format is very simple. That’s why compression works quite well.
Just for fun: if you use a recent diff on vm with low activity on binary files, you can use the command strings on it, and you will mostly see logs & text files:

strings /tmp/vm-139-disk-0_20220123-17h43-20220123-22h49
List all volumes including snapshots on the cephblock pool
root@pve1:~# rbd ls -l cephblock      
NAME                          SIZE    PARENT  FMT  PROT  LOCK
vm-101-disk-0                 40 GiB            2        excl
vm-105-disk-0                 15 GiB            2        excl
vm-134-disk-0                 40 GiB            2        excl
vm-139-disk-0                 15 GiB            2        excl
vm-139-disk-0@20220123-17h43  15 GiB            2             
vm-139-disk-0@20220123-22h49  15 GiB            2             
vm-139-disk-0@20220124-00h19  15 GiB            2            

You can grep on those containing @ to get only snapshots.

Get the VM name by vmid

This might be useful for scripting to include de VM/CT name in the filename. Might not be the best solution, but this is a possible way.

root@pve1:~# vmid=139
root@pve1:~# vmname=$(pvesh get /cluster/resources --type vm --output-format json | jq -r ".[] | select(.vmid==$vmid) | .name " | tr -cd "[:alnum:]")
root@pve1:~# echo $vmname
freepbx
Restore the base snapshot

Then import, and import the diff… (check rbd manual)

Get the GB used in the ‘cephblock’ pool

rados -p cephblock -f json df | jq '.pools [0] .size_kb/1024/1024 | ceil'

[Need assistance with a different issue? Our team is available 24/7.]

Conclusion

In conclusion, our Support Engineers demonstrated CEPH proxmox backup. Furthermore, we went through different causes and solutions for this specific error.

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

Never again lose customers to poor
server speed! Let us help you.

Privacy Preference Center

Necessary

Necessary cookies help make a website usable by enabling basic functions like page navigation and access to secure areas of the website. The website cannot function properly without these cookies.

PHPSESSID - Preserves user session state across page requests.

gdpr[consent_types] - Used to store user consents.

gdpr[allowed_cookies] - Used to store user allowed cookies.

PHPSESSID, gdpr[consent_types], gdpr[allowed_cookies]
PHPSESSID
WHMCSpKDlPzh2chML

Statistics

Statistic cookies help website owners to understand how visitors interact with websites by collecting and reporting information anonymously.

_ga - Preserves user session state across page requests.

_gat - Used by Google Analytics to throttle request rate

_gid - Registers a unique ID that is used to generate statistical data on how you use the website.

smartlookCookie - Used to collect user device and location information of the site visitors to improve the websites User Experience.

_ga, _gat, _gid
_ga, _gat, _gid
smartlookCookie
_clck, _clsk, CLID, ANONCHK, MR, MUID, SM

Marketing

Marketing cookies are used to track visitors across websites. The intention is to display ads that are relevant and engaging for the individual user and thereby more valuable for publishers and third party advertisers.

IDE - Used by Google DoubleClick to register and report the website user's actions after viewing or clicking one of the advertiser's ads with the purpose of measuring the efficacy of an ad and to present targeted ads to the user.

test_cookie - Used to check if the user's browser supports cookies.

1P_JAR - Google cookie. These cookies are used to collect website statistics and track conversion rates.

NID - Registers a unique ID that identifies a returning user's device. The ID is used for serving ads that are most relevant to the user.

DV - Google ad personalisation

_reb2bgeo - The visitor's geographical location

_reb2bloaded - Whether or not the script loaded for the visitor

_reb2bref - The referring URL for the visit

_reb2bsessionID - The visitor's RB2B session ID

_reb2buid - The visitor's RB2B user ID

IDE, test_cookie, 1P_JAR, NID, DV, NID
IDE, test_cookie
1P_JAR, NID, DV
NID
hblid
_reb2bgeo, _reb2bloaded, _reb2bref, _reb2bsessionID, _reb2buid

Security

These are essential site cookies, used by the google reCAPTCHA. These cookies use an unique identifier to verify if a visitor is human or a bot.

SID, APISID, HSID, NID, PREF
SID, APISID, HSID, NID, PREF