mirror of
https://github.com/kopia/kopia.git
synced 2026-03-12 11:16:25 -04:00
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.
49 lines
1.3 KiB
Go
49 lines
1.3 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"io/ioutil"
|
|
|
|
"github.com/alecthomas/kingpin"
|
|
|
|
"github.com/kopia/kopia/repo/blob"
|
|
"github.com/kopia/kopia/repo/blob/rclone"
|
|
)
|
|
|
|
func init() {
|
|
var (
|
|
opt rclone.Options
|
|
connectFlat bool
|
|
embedRCloneConfigFile string
|
|
)
|
|
|
|
RegisterStorageConnectFlags(
|
|
"rclone",
|
|
"an rclone-based provided",
|
|
func(cmd *kingpin.CmdClause) {
|
|
cmd.Flag("remote-path", "Rclone remote:path").Required().StringVar(&opt.RemotePath)
|
|
cmd.Flag("flat", "Use flat directory structure").BoolVar(&connectFlat)
|
|
cmd.Flag("rclone-exe", "Path to rclone binary").StringVar(&opt.RCloneExe)
|
|
cmd.Flag("rclone-args", "Pass additional parameters to rclone").StringsVar(&opt.RCloneArgs)
|
|
cmd.Flag("rclone-env", "Pass additional environment (key=value) to rclone").StringsVar(&opt.RCloneEnv)
|
|
cmd.Flag("embed-rclone-config", "Embed the provider RClone config").ExistingFileVar(&embedRCloneConfigFile)
|
|
},
|
|
func(ctx context.Context, isNew bool) (blob.Storage, error) {
|
|
if connectFlat {
|
|
opt.DirectoryShards = []int{}
|
|
}
|
|
|
|
if embedRCloneConfigFile != "" {
|
|
cfg, err := ioutil.ReadFile(embedRCloneConfigFile) //nolint:gosec
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
opt.EmbeddedConfig = string(cfg)
|
|
}
|
|
|
|
return rclone.New(ctx, &opt)
|
|
},
|
|
)
|
|
}
|