Copy images locally

Hello,

I am in the process of auto-updating some images. For that I

  • Spin up a temporary container
  • Do the changes
  • Use lxc publish … --reuse

What I would like to do before all that, copy the currently existing image as a fallback/backup, in case the automatic update does some weird things…

I would have expected that something like lxc image copy source-image-name local: --alias gh-source-image-name-backup Works (maybe even with some reuse or force flag to override an existing image). But that only fails with

Error: Cannot copy an image within the same server and project

Is there a way to accomplish that?

I can export an image and then import it again of course, but that feels counter intuitive.

If your goal is only a rollback point, I would not copy the image data. Images are content-addressed, so you can keep the old fingerprint and give it a second alias before publishing the new one, for example: `old=$(lxc image info gh-source-image-name | awk ‘/Fingerprint:/ {print $2}’)` and then `lxc image alias create gh-source-image-name-backup $old`. After `publish --reuse` moves the main alias, the backup alias should still point at the previous image.