Compare commits
2 Commits
main
...
116-pitr-c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
653a79bde9 | ||
|
|
a0ebe13565 |
@ -95,7 +95,7 @@ func addExchangeCommands(cmd *cobra.Command) *cobra.Command {
|
||||
c, fs = utils.AddCommand(cmd, exchangeListCmd())
|
||||
fs.SortFlags = false
|
||||
|
||||
utils.AddBackupIDFlag(c, false)
|
||||
utils.AddDetailsAndRestoreFlags(c, false)
|
||||
addFailedItemsFN(c)
|
||||
addSkippedItemsFN(c)
|
||||
addRecoveredErrorsFN(c)
|
||||
@ -111,7 +111,7 @@ func addExchangeCommands(cmd *cobra.Command) *cobra.Command {
|
||||
|
||||
// Flags addition ordering should follow the order we want them to appear in help and docs:
|
||||
// More generic (ex: --user) and more frequently used flags take precedence.
|
||||
utils.AddBackupIDFlag(c, true)
|
||||
utils.AddDetailsAndRestoreFlags(c, true)
|
||||
utils.AddExchangeDetailsAndRestoreFlags(c)
|
||||
|
||||
case deleteCommand:
|
||||
|
||||
@ -78,7 +78,7 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command {
|
||||
c, fs = utils.AddCommand(cmd, oneDriveListCmd())
|
||||
fs.SortFlags = false
|
||||
|
||||
utils.AddBackupIDFlag(c, false)
|
||||
utils.AddDetailsAndRestoreFlags(c, false)
|
||||
addFailedItemsFN(c)
|
||||
addSkippedItemsFN(c)
|
||||
addRecoveredErrorsFN(c)
|
||||
@ -91,7 +91,7 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command {
|
||||
c.Example = oneDriveServiceCommandDetailsExamples
|
||||
|
||||
options.AddSkipReduceFlag(c)
|
||||
utils.AddBackupIDFlag(c, true)
|
||||
utils.AddDetailsAndRestoreFlags(c, true)
|
||||
utils.AddOneDriveDetailsAndRestoreFlags(c)
|
||||
|
||||
case deleteCommand:
|
||||
|
||||
@ -94,7 +94,7 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
||||
c, fs = utils.AddCommand(cmd, sharePointListCmd())
|
||||
fs.SortFlags = false
|
||||
|
||||
utils.AddBackupIDFlag(c, false)
|
||||
utils.AddDetailsAndRestoreFlags(c, false)
|
||||
addFailedItemsFN(c)
|
||||
addSkippedItemsFN(c)
|
||||
addRecoveredErrorsFN(c)
|
||||
@ -107,7 +107,7 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
||||
c.Example = sharePointServiceCommandDetailsExamples
|
||||
|
||||
options.AddSkipReduceFlag(c)
|
||||
utils.AddBackupIDFlag(c, true)
|
||||
utils.AddDetailsAndRestoreFlags(c, true)
|
||||
utils.AddSharePointDetailsAndRestoreFlags(c)
|
||||
|
||||
case deleteCommand:
|
||||
|
||||
@ -23,6 +23,8 @@ func Control() control.Options {
|
||||
opt.ToggleFeatures.DisableConcurrencyLimiter = disableConcurrencyLimiterFV
|
||||
opt.Parallelism.ItemFetch = fetchParallelismFV
|
||||
|
||||
opt.Repo.ViewTimestamp = viewTimestampFV.Get()
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
@ -40,6 +42,7 @@ const (
|
||||
DisableIncrementalsFN = "disable-incrementals"
|
||||
EnableImmutableIDFN = "enable-immutable-id"
|
||||
DisableConcurrencyLimiterFN = "disable-concurrency-limiter"
|
||||
ViewTimestampFN = "point-in-time"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -48,6 +51,7 @@ var (
|
||||
noStatsFV bool
|
||||
restorePermissionsFV bool
|
||||
skipReduceFV bool
|
||||
viewTimestampFV timestamp
|
||||
)
|
||||
|
||||
// AddGlobalOperationFlags adds the global operations flag set.
|
||||
@ -90,6 +94,17 @@ func AddFetchParallelismFlag(cmd *cobra.Command) {
|
||||
cobra.CheckErr(fs.MarkHidden(FetchParallelismFN))
|
||||
}
|
||||
|
||||
// AddViewTimestampFlag adds a hidden flag that allows callers to pass a
|
||||
// timestamp to view the corso repo at if immutable backups are enabled.
|
||||
func AddViewTimestampFlag(cmd *cobra.Command) {
|
||||
fs := cmd.Flags()
|
||||
fs.Var(
|
||||
&viewTimestampFV,
|
||||
ViewTimestampFN,
|
||||
"View the repository at a previous datetime by passing an RFC3339 timestamp")
|
||||
cobra.CheckErr(fs.MarkHidden(ViewTimestampFN))
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
// Feature Flags
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
@ -32,7 +32,7 @@ func addExchangeCommands(cmd *cobra.Command) *cobra.Command {
|
||||
// general flags
|
||||
fs.SortFlags = false
|
||||
|
||||
utils.AddBackupIDFlag(c, true)
|
||||
utils.AddDetailsAndRestoreFlags(c, true)
|
||||
utils.AddExchangeDetailsAndRestoreFlags(c)
|
||||
options.AddFailFastFlag(c)
|
||||
}
|
||||
|
||||
@ -31,7 +31,7 @@ func addOneDriveCommands(cmd *cobra.Command) *cobra.Command {
|
||||
// More generic (ex: --user) and more frequently used flags take precedence.
|
||||
fs.SortFlags = false
|
||||
|
||||
utils.AddBackupIDFlag(c, true)
|
||||
utils.AddDetailsAndRestoreFlags(c, true)
|
||||
utils.AddOneDriveDetailsAndRestoreFlags(c)
|
||||
|
||||
// restore permissions
|
||||
|
||||
@ -31,7 +31,7 @@ func addSharePointCommands(cmd *cobra.Command) *cobra.Command {
|
||||
// More generic (ex: --site) and more frequently used flags take precedence.
|
||||
fs.SortFlags = false
|
||||
|
||||
utils.AddBackupIDFlag(c, true)
|
||||
utils.AddDetailsAndRestoreFlags(c, true)
|
||||
utils.AddSharePointDetailsAndRestoreFlags(c)
|
||||
|
||||
options.AddRestorePermissionsFlag(c)
|
||||
|
||||
@ -8,6 +8,7 @@ import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/pflag"
|
||||
|
||||
"github.com/alcionai/corso/src/cli/options"
|
||||
"github.com/alcionai/corso/src/internal/common/dttm"
|
||||
"github.com/alcionai/corso/src/pkg/control/repository"
|
||||
"github.com/alcionai/corso/src/pkg/path"
|
||||
@ -84,6 +85,11 @@ func AddBackupIDFlag(cmd *cobra.Command, require bool) {
|
||||
}
|
||||
}
|
||||
|
||||
func AddDetailsAndRestoreFlags(cmd *cobra.Command, require bool) {
|
||||
AddBackupIDFlag(cmd, require)
|
||||
options.AddViewTimestampFlag(cmd)
|
||||
}
|
||||
|
||||
func AddDataFlag(cmd *cobra.Command, allowed []string, hide bool) {
|
||||
var (
|
||||
allowedMsg string
|
||||
|
||||
@ -71,7 +71,7 @@ func NewConn(s storage.Storage) *conn {
|
||||
}
|
||||
|
||||
func (w *conn) Initialize(ctx context.Context, opts repository.Options) error {
|
||||
bst, err := blobStoreByProvider(ctx, w.storage)
|
||||
bst, err := blobStoreByProvider(ctx, opts, w.storage)
|
||||
if err != nil {
|
||||
return clues.Wrap(err, "initializing storage")
|
||||
}
|
||||
@ -111,7 +111,7 @@ func (w *conn) Initialize(ctx context.Context, opts repository.Options) error {
|
||||
}
|
||||
|
||||
func (w *conn) Connect(ctx context.Context, opts repository.Options) error {
|
||||
bst, err := blobStoreByProvider(ctx, w.storage)
|
||||
bst, err := blobStoreByProvider(ctx, opts, w.storage)
|
||||
if err != nil {
|
||||
return clues.Wrap(err, "initializing storage")
|
||||
}
|
||||
@ -174,10 +174,14 @@ func (w *conn) commonConnect(
|
||||
return nil
|
||||
}
|
||||
|
||||
func blobStoreByProvider(ctx context.Context, s storage.Storage) (blob.Storage, error) {
|
||||
func blobStoreByProvider(
|
||||
ctx context.Context,
|
||||
opts repository.Options,
|
||||
s storage.Storage,
|
||||
) (blob.Storage, error) {
|
||||
switch s.Provider {
|
||||
case storage.ProviderS3:
|
||||
return s3BlobStorage(ctx, s)
|
||||
return s3BlobStorage(ctx, opts, s)
|
||||
default:
|
||||
return nil, clues.New("storage provider details are required").WithClues(ctx)
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import (
|
||||
"github.com/kopia/kopia/repo/blob"
|
||||
"github.com/kopia/kopia/repo/blob/s3"
|
||||
|
||||
"github.com/alcionai/corso/src/pkg/control/repository"
|
||||
"github.com/alcionai/corso/src/pkg/storage"
|
||||
)
|
||||
|
||||
@ -14,7 +15,11 @@ const (
|
||||
defaultS3Endpoint = "s3.amazonaws.com" // matches kopia's default value
|
||||
)
|
||||
|
||||
func s3BlobStorage(ctx context.Context, s storage.Storage) (blob.Storage, error) {
|
||||
func s3BlobStorage(
|
||||
ctx context.Context,
|
||||
repoOpts repository.Options,
|
||||
s storage.Storage,
|
||||
) (blob.Storage, error) {
|
||||
cfg, err := s.S3Config()
|
||||
if err != nil {
|
||||
return nil, clues.Stack(err).WithClues(ctx)
|
||||
@ -36,6 +41,7 @@ func s3BlobStorage(ctx context.Context, s storage.Storage) (blob.Storage, error)
|
||||
RoleARN: s.Role,
|
||||
RoleDuration: s.SessionDuration,
|
||||
TLSHandshakeTimeout: 60,
|
||||
PointInTime: repoOpts.ViewTimestamp,
|
||||
}
|
||||
|
||||
store, err := s3.New(ctx, &opts, false)
|
||||
|
||||
@ -1,9 +1,16 @@
|
||||
package repository
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
// Repo represents options that are specific to the repo storing backed up data.
|
||||
type Options struct {
|
||||
User string `json:"user"`
|
||||
Host string `json:"host"`
|
||||
// ViewTimestamp is the time at which the repo should be opened at if
|
||||
// immutable backups are being used. If nil then the current time is used.
|
||||
ViewTimestamp *time.Time `json:"viewTimestamp"`
|
||||
}
|
||||
|
||||
type Maintenance struct {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user