Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add storage bucket backup #365

Merged
merged 14 commits into from
Feb 19, 2024
Merged

Conversation

maveonair
Copy link
Member

@maveonair maveonair commented Jan 4, 2024

This pull request add backup support for storage buckets from #241.

Description

Export

CLI

$ incus storage bucket export
Description:
  Export storage buckets as tarball.

Usage:
  incus storage bucket export [<remote>:]<pool> <bucket> [<path>] [flags]

Examples:
  incus storage bucket default b1
      Download a backup tarball of the b1 storage bucket.

Flags:
      --compression   Define a compression algorithm: for backup or none
      --target        Cluster member name

Global Flags:
      --debug          Show all debug messages
      --force-local    Force using the local unix socket
  -h, --help           Print help
      --project        Override the source project
  -q, --quiet          Don't show progress information
      --sub-commands   Use with help or --help to view sub-commands
  -v, --verbose        Show all information messages
      --version        Print version number
$ incus storage bucket export default bucket0
Backup exported successfully!                      

Archive

The export command creates a tarball from the defined bucket, which is structured as follows:

bucket0.tar.gz
├── backup
│   └── index.yaml
│   └── bucket
    │   └── file1
    │   └── file2
  • backup.yml: contains the bucket metadata and keys
name: bucket0
backend: dir
pool: default
config:
  bucket:
    config: {}
    description: ""
    name: bucket0
    s3_url: ""
    location: none
  bucket_keys:
  - description: Admin user
    role: admin
    access-key: OO9O3OXLJWMED0W8P2I5
    secret-key: Ny4W9glDRFks7DzxlPQibREOAUSc1De9Yv0mOkuY
    name: admin
  - description: ""
    role: read-only
    access-key: JIY5PI6RPQWP7CAKJN57
    secret-key: APC95jzb9u7XUKw7J7AWAdVnaNVbjqj5dOLddkhT
    name: reader
  • bucket: This folder contains the actual data

API

This includes the following new endpoints (see RESTful API for details):

  • GET /1.0/storage-pools/<pool>/buckets/<bucket>/backups

  • POST /1.0/storage-pools/<pool>/buckets/<bucket>/backups

  • GET /1.0/storage-pools/<pool>/buckets/<bucket>/backups/<name>

  • POST /1.0/storage-pools/<pool>/buckets/<bucket>/backups/<name>

  • DELETE /1.0/storage-pools/<pool>/buckets/<bucket>/backups/<name>

  • GET /1.0/storage-pools/<pool>/buckets/<bucket>/backups/<name>/export

Export

CLI

$ incus storage bucket import
Description:
  Import backups of storage buckets.

Usage:
  incus storage bucket import [<remote>:]<pool> <backup file> [<bucket>] [flags]

Examples:
  incus storage bucket import default backup0.tar.gz
                Create a new storage bucket using backup0.tar.gz as the source.

Flags:
      --target   Cluster member name

Global Flags:
      --debug          Show all debug messages
      --force-local    Force using the local unix socket
  -h, --help           Print help
      --project        Override the source project
  -q, --quiet          Don't show progress information
      --sub-commands   Use with help or --help to view sub-commands
  -v, --verbose        Show all information messages
      --version        Print version number
$ incus storage bucket import default backup.tar.gz bucket0
Backup exported successfully!                      

Design decisions

  • One of the existing bucket keys is used by default, as everyone can at least read the bucket.

What's been changed

  • The command storage bucket export and storage bucket import has been added to the command line interface (CLI).
  • New APIs added
  • Added new functionality for performing storage bucket backups and cleaning up expired backups
  • Added new functionality for importing storage bucket backups
  • Updated API and CLI documentation

@github-actions github-actions bot added Documentation Documentation needs updating API Changes to the REST API labels Jan 4, 2024
@maveonair maveonair force-pushed the storage-buckets-backup branch 9 times, most recently from 07b814e to 9acf4c9 Compare January 9, 2024 19:49
@maveonair
Copy link
Member Author

@stgraber I'd love to get some early feedback on the "Storage Bucket Export" implementation as I tackle the import feature.

@stgraber
Copy link
Member

By default, we try to use the admin key to export an existing bucket, but it is also possible to specify any key that has access to the bucket with the --key flag.

Given that Incus is in charge of the keys to begin with and currently all keys allow for downloads, I don't think we need to provide that flag, Incus will just pick up a key from the list of keys and use that to fetch the data.

cmd/incusd/api_1.0.go Outdated Show resolved Hide resolved
@maveonair maveonair force-pushed the storage-buckets-backup branch 8 times, most recently from 624a565 to bb02a1d Compare January 12, 2024 22:05
@maveonair maveonair force-pushed the storage-buckets-backup branch 7 times, most recently from 4329eee to a1e3ffe Compare February 19, 2024 07:07
@maveonair
Copy link
Member Author

@stgraber I customized the test suite to run only on the dir and ceph backend as we discussed and the test run was now successful 🎉.

@maveonair maveonair force-pushed the storage-buckets-backup branch 2 times, most recently from dd5ff2f to a16957a Compare February 19, 2024 10:42
@stgraber
Copy link
Member

Looks good. There are a couple of minor commit re-shuffle that I want to do on top of this but I'll do that myself and then merge, thanks!

@stgraber stgraber merged commit 72eaabb into lxc:main Feb 19, 2024
25 checks passed
@maveonair maveonair deleted the storage-buckets-backup branch February 19, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Changes to the REST API Documentation Documentation needs updating Incomplete Waiting on more information from reporter
Development

Successfully merging this pull request may close these issues.

2 participants