0

Is it possible to pipe the output of rbd export directly to something else like tar to create a compressed archive of the .img file without having to write to disk first?

Something like

rbd export Pool/image | tar -czvf image.img.zst

Or do I just have to use some disk as a middleman to create the archive?

cclloyd
  • 583
  • 1
  • 13
  • 24
  • 1
    Does it have to be `tar`? Would something like `rbd export pool/image - | gzip -k9 > rbdexport.gzip` work for you? – eblock Feb 09 '21 at 08:06
  • @eblock not necessarily. Just a way to trim all the empty space in the image, which is basically any archive format. That worked perfectly. Thank you. – cclloyd Feb 10 '21 at 02:51

1 Answers1

0

If you need to sparsify the archived image during rbd export you can use:

rbd export pool/image - | gzip -k9 > rbdexport.gzip

To sparsify the image on the fly without having to export it there's a sparsifycommand for that, for example if you can't trim the space from within the VM (I assume you're using rbd for virtual machines):

rbd sparsify pool/image
eblock
  • 215
  • 1
  • 4
  • Actually they're a kubernetes PV backend. This is just a way of having backups of the images not within my existing storage infrastructure. Though how would I import the compressed image? It seems to require a file to do `rbd import`. – cclloyd Feb 10 '21 at 18:45
  • The import works the other way around, of course. But you'll have to unzip it first before importing it. The import works like this: `rbd import /`. – eblock Feb 11 '21 at 07:32