mirror of
https://github.com/kopia/kopia.git
synced 2025-12-23 22:57:50 -05:00
This adds new set of APIs `/api/v1/control/*` which can be used to administratively control a running server. Once the server is started, the administrative user can control it using CLI commands: export KOPIA_SERVER_ADDRESS=... export KOPIA_SERVER_CERT_FINGERPRINT=... export KOPIA_SERVER_PASSWORD=... * `kopia server status` - displays status of sources managed by the server * `kopia server snapshot` - triggers server-side upload of snapshots for managed sources * `kopia server cancel` - cancels upload of snapshots for managed sources * `kopia server pause` - pauses scheduled snapshots for managed sources * `kopia server resume` - resumes scheduled snapshots for managed sources * `kopia server refresh` - causes server to resynchronize with externally-made changes, such as policies or new sources * `kopia server flush` - causes server to flush all pending writes * `kopia server shutdown` - graceful shutdown of the server Authentication uses new user `server-control` and is disabled by default. To enable it when starting the server, provide the password using one of the following methods: * `--server-control-password` * `--random-server-control-password` * `.htpasswd` file * `KOPIA_SERVER_CONTROL_PASSWORD` environment variable This change allows us to tighten the API security and remove some methods that UI user was able to call, but which were not needed.
23 lines
607 B
Go
23 lines
607 B
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/kopia/kopia/internal/apiclient"
|
|
)
|
|
|
|
type commandServerUpload struct {
|
|
commandServerSourceManagerAction
|
|
}
|
|
|
|
func (c *commandServerUpload) setup(svc appServices, parent commandParent) {
|
|
cmd := parent.Command("snapshot", "Trigger upload for one or more existing sources").Alias("upload")
|
|
|
|
c.commandServerSourceManagerAction.setup(svc, cmd)
|
|
cmd.Action(svc.serverAction(&c.sf, c.run))
|
|
}
|
|
|
|
func (c *commandServerUpload) run(ctx context.Context, cli *apiclient.KopiaAPIClient) error {
|
|
return c.triggerActionOnMatchingSources(ctx, cli, "control/trigger-snapshot")
|
|
}
|