diff options
author | James Fargher <jfargher@gitlab.com> | 2023-06-15 04:33:23 +0300 |
---|---|---|
committer | James Fargher <jfargher@gitlab.com> | 2023-06-19 06:31:48 +0300 |
commit | 01372a56b90352aa9fa0da3bbf1d8f158b9932ca (patch) | |
tree | 8e865c0c26c375492cd119966bca94b0c1722dfc /cmd | |
parent | 19bc27b5cc7f859789b99c0a1ce5cdd5ab314d98 (diff) |
gitaly-backup: Add backup-id option to restore command
Allow the backup-id to be specified by the user. The manager backup ID
used to be arbitrarily set to a timestamp. This matches what the create
command does. It never used to matter because the backup ID was ignored
on restore.
Changelog: changed
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly-backup/restore.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/cmd/gitaly-backup/restore.go b/cmd/gitaly-backup/restore.go index 7c910e31e..093238505 100644 --- a/cmd/gitaly-backup/restore.go +++ b/cmd/gitaly-backup/restore.go @@ -9,7 +9,6 @@ import ( "io" "runtime" "strings" - "time" log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/v16/client" @@ -33,6 +32,7 @@ type restoreSubcommand struct { parallelStorage int layout string removeAllRepositories []string + backupID string } func (cmd *restoreSubcommand) Flags(fs *flag.FlagSet) { @@ -44,6 +44,7 @@ func (cmd *restoreSubcommand) Flags(fs *flag.FlagSet) { cmd.removeAllRepositories = strings.Split(removeAll, ",") return nil }) + fs.StringVar(&cmd.backupID, "id", "", "ID of full backup to restore. If not specified, the latest backup is restored.") } func (cmd *restoreSubcommand) Run(ctx context.Context, stdin io.Reader, stdout io.Writer) error { @@ -60,7 +61,7 @@ func (cmd *restoreSubcommand) Run(ctx context.Context, stdin io.Reader, stdout i pool := client.NewPool(internalclient.UnaryInterceptor(), internalclient.StreamInterceptor()) defer pool.Close() - manager := backup.NewManager(sink, locator, pool, time.Now().UTC().Format("20060102150405")) + manager := backup.NewManager(sink, locator, pool, cmd.backupID) logger := log.StandardLogger() for _, storageName := range cmd.removeAllRepositories { |