Backup api vs lxc client equivalent?

Like many other user of LXD, I have been making backup of my container using lxd image technic, now I am converting to lxc export.

I was looking at the api backup doc and also at the backup code inside lxdMosaic, and was wandering how could I do the same from the command line?, or is there some config setting I could use ?

I don’t really understand what you mean.

lxc export is one option for command line.
Another idea would be to use snapshots, with lxc snapshot.
Afaik you can also automate backups with snapshots.

Or do you mean something else?

Sorry English is not my first language.

Yes I do have automatique snapshot running on my server and auto expired.

I do make use of lxc export every night, lxc copy also.

My question was regarding the /1.0/instances/<name>/backups API.

This is someting that I try to understand and would like to use, I do not want to use third party tools “ex: LxdMosaic backup” if I do not know how it works.


Backups are fun!

I mean you mention LXDMosaic :angel: but can I ask why you aren’t happy with the LXDMosaic solution?

To simplify LXDMosaic;

You just want to write cron jobs to hit POST /1.0/INSTANCE/backups then GET /1.0/INSTANCE/backups/BACKUP_NAME/export then DELETE /1.0/INSTANCE/backups/BACKUP_NAME

Hi Turtle, No I am very happy with LXDMosaic, been testing it since early version :slight_smile:

As an old sysadmin, I need to understand under the hood how it work.

Also I love to use bash stuff for automation.

I have been fight to use lxc query -X post to mimic what you do in LXDMosaic. whitout success

lxc query -X POST { “name”: “backup0”, “expiry”: 3600, “instance_only”: true, “optimized_storage”: true } /1.0/containers/one/backups/backup0
Send a raw query to LXD

lxc query [:] [flags]

lxc query -X DELETE --wait /1.0/instances/c1
Delete local instance “c1”.

-d, --data Input data
–raw Print the raw response
-X, --request Action (defaults to GET) (default “GET”)
–wait Wait for the operation to complete

Global Flags:
–debug Show all debug messages
–force-local Force using the local unix socket
-h, --help Print help
–project string Override the source project
-q, --quiet Don’t show progress information
-v, --verbose Show all information messages
–version Print version number
Error: Invalid number of arguments

Oh okay,

well I guess its this

lxc query -X POST --data '{"name": "wow"}' /1.0/instances/INSTANCE_NAME/backups

You have to wait for the backup operation to finish here

lxc query /1.0/instances/INSTANCE_NAME/backups/wow/export > my_backup.tar.gz

lxc query -X DELETE /1.0/instances/INSTANCE_NAME/backups/wow

1 Like

Tanks a Lot, I am doing a backup now…

Funny how simple thing cant get so bizzare without documentation !!!

I will try to implement some lxc alias for this !

Also will come back to you concerning the usage of storage.backups_volume in lxdMosaic

lxc config show
core.https_address: ‘[::]:8443’
core.trust_password: true
storage.backups_volume: bkp_pool/bkp_vol

Best regard

We’ve not yet had much use for exposing all the capabilities of the backups API in the CLI. Instead we just have lxc export and lxc import which make use of it.

lxc export just creates a new backup, then downloads it, then deletes it, pretty much exactly as you did above through lxc query.