Files
kopia/cli/storage_webdav.go
Jarek Kowalski ad4b222939 cli: added support for copying (or moving) snapshot history (#703)
Both source and destination can be specified using user@host,
@host or user@host:/path where destination values override the
corresponding parts of the source, so both targeted
and mass copying is supported.

Supported combinations are:

Source:             Destination         Behavior
---------------------------------------------------
@host1              @host2              copy snapshots from all users of host1
user1@host1         @host2              copy all snapshots to user1@host2
user1@host1         user2@host2         copy all snapshots to user2@host2
user1@host1:/path1  @host2              copy to user1@host2:/path1
user1@host1:/path1  user2@host2         copy to user2@host2:/path1
user1@host1:/path1  user2@host2:/path2  copy snapshots from single path

When --move is specified, the matching source snapshots are also deleted.

* cli: upgraded kingpin to latest version (not tagged)

This allows using `EnableFileExpansion` to disable treating
arguments prefixed with "@" as file includes.
2020-12-04 16:34:55 -08:00

46 lines
1.0 KiB
Go

package cli
import (
"context"
"github.com/alecthomas/kingpin"
"github.com/kopia/kopia/repo/blob"
"github.com/kopia/kopia/repo/blob/webdav"
)
func init() {
var (
options webdav.Options
connectFlat bool
)
RegisterStorageConnectFlags(
"webdav",
"a WebDAV storage",
func(cmd *kingpin.CmdClause) {
cmd.Flag("url", "URL of WebDAV server").Required().StringVar(&options.URL)
cmd.Flag("flat", "Use flat directory structure").BoolVar(&connectFlat)
cmd.Flag("webdav-username", "WebDAV username").Envar("KOPIA_WEBDAV_USERNAME").StringVar(&options.Username)
cmd.Flag("webdav-password", "WebDAV password").Envar("KOPIA_WEBDAV_PASSWORD").StringVar(&options.Password)
},
func(ctx context.Context, isNew bool) (blob.Storage, error) {
wo := options
if wo.Username != "" && wo.Password == "" {
pass, err := askPass("Enter WebDAV password: ")
if err != nil {
return nil, err
}
wo.Password = pass
}
if connectFlat {
wo.DirectoryShards = []int{}
}
return webdav.New(ctx, &wo)
})
}