Files
kopia/cli/command_server_pause.go
Jarek Kowalski 2e9a57f0b4 server: support for server control APIs and tooling (#1644)
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.
2022-01-03 18:48:38 -08:00

22 lines
586 B
Go

package cli
import (
"context"
"github.com/kopia/kopia/internal/apiclient"
)
type commandServerPause struct {
commandServerSourceManagerAction
}
func (c *commandServerPause) setup(svc appServices, parent commandParent) {
cmd := parent.Command("pause", "Pause the scheduled snapshots for one or more sources")
c.commandServerSourceManagerAction.setup(svc, cmd)
cmd.Action(svc.serverAction(&c.sf, c.run))
}
func (c *commandServerPause) run(ctx context.Context, cli *apiclient.KopiaAPIClient) error {
return c.triggerActionOnMatchingSources(ctx, cli, "control/pause-source")
}