How can I move a snapshot to another system and restore it?


I have some snapshots on System 1.

I want to move it to System 2 which has the same base image as System 1.

How can I achieve this? Is this possible?

The reason I ask is if we take a daily snapshot of a running machine (System 1) and it crashes and we need to boot up the previous days snapshot on another machine (System 2) while we diagnose what went wrong with System 1.



Is this LXC or LXD?

1 Like

I have made the containers in LXC… But I thought LXD was the daemon for LXC?

lxc is the client to lxd. Your post used the category LXC which is for posts to do with the earlier Linux Containers - LXC - Introduction project. I’ve changed it now for you.

Anyway, now we’ve established you’re referring to LXD:

You can copy a snapshot to another host as a new instance using:

lxc copy <instance_name>/<snapshot_name> <remote_name>:<new_instance_name>

You’ll need to enable the LXD servers to be listening on the network by using:

lxc set core.https_address=<listen_ip_address>

And then setup trust token on your target LXD host using:

lxc config trust add

And then add a remote to your local lxc client using:

lxc remote add <remote_name> <token generated above>

Ahh I see, Thank you for clearing that up :slight_smile:

Could I then load the snapshot on a new image?

For instance if they are both using Ubuntu 22.04 could I then
take a snapshot each day and then if that VM fails start a new VM
and do something like the following?

  • lxd init,
  • launch a new ubuntu 22.04 instance,
  • and then load the snapshot.
    Would that work?

I’m not following you im afraid.

The copy of the snapshot will be a new instance in its own right.

You could use lxc copy <instance> <remote>:<new instance> --refresh which will backup any changes between the two instances (and any snapshots taken on the source that are not on the target yet).

You could then do lxc restore <instance> <snapshot> on the target system to restore a snapshot that was copied from the source machine.


Sorry, I’m not explaining myself well.

So AFAIK A Snapshot if just a snapshot of the filesystem and can only be recreated
on the machine that Snapshot was created on?

What I was trying to ask ultimately is can I take Snapshots as backups and then transfer then to a storage pool, and if I need to restore this snapshot I can search for a snapshot taken 1 year ago and restore it on a different machine it was created on?

lxc copy <instance> <remote>:<new instance> --refresh

Is a nice command! I was thinking of using Rsync to only transfer the changes between Snapshots but this is probably better. And I assume you will always need the base Snapshot to recover since it only holds the changes between point A and point B?

Yes that command will use rsync under the hood or an optimized transfer protocol (for storage pools that support it).

Either way it will transfer all snapshots to the target, with each more recent one being based on the difference of the prior one. Finally it will transfer the current instance based on the difference from the last snapshot.

1 Like