forked from wal-g/wal-g
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request wal-g#1502 from rdjjke/backup-push-failover-storages
Support failover storages in `backup-push` and backups in `st transfer`
- Loading branch information
Showing
60 changed files
with
2,080 additions
and
931 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package st | ||
|
||
import ( | ||
"math" | ||
|
||
"github.com/spf13/cobra" | ||
"github.com/wal-g/tracelog" | ||
"github.com/wal-g/wal-g/internal/storagetools/transfer" | ||
) | ||
|
||
const backupsShortDescription = "Moves all backups from one storage to another" | ||
|
||
// backupsCmd represents the backups command | ||
var backupsCmd = &cobra.Command{ | ||
Use: "backups [backup_name] --source='source_storage' [--target='target_storage']", | ||
Short: backupsShortDescription, | ||
Args: cobra.RangeArgs(0, 1), | ||
Run: func(_ *cobra.Command, args []string) { | ||
var fileLister transfer.FileLister | ||
if len(args) == 0 { | ||
fileLister = transfer.NewAllBackupsFileLister(transferOverwrite, int(transferMaxFiles), int(transferMaxBackups)) | ||
} else { | ||
fileLister = transfer.NewSingleBackupFileLister(args[0], transferOverwrite, int(transferMaxFiles)) | ||
} | ||
|
||
cfg := &transfer.HandlerConfig{ | ||
FailOnFirstErr: transferFailFast, | ||
Concurrency: transferConcurrency, | ||
AppearanceChecks: transferAppearanceChecks, | ||
AppearanceChecksInterval: transferAppearanceChecksInterval, | ||
} | ||
|
||
handler, err := transfer.NewHandler(transferSourceStorage, targetStorage, fileLister, cfg) | ||
tracelog.ErrorLogger.FatalOnError(err) | ||
|
||
err = handler.Handle() | ||
tracelog.ErrorLogger.FatalOnError(err) | ||
}, | ||
} | ||
|
||
var transferMaxBackups uint | ||
|
||
func init() { | ||
backupsCmd.Flags().UintVar(&transferMaxBackups, "max-backups", math.MaxInt, | ||
"max number of backups to move in this run. Is ignored if backup_name is specified") | ||
|
||
transferCmd.AddCommand(backupsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package st | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/wal-g/tracelog" | ||
"github.com/wal-g/wal-g/internal/storagetools/transfer" | ||
) | ||
|
||
const filesShortDescription = "Moves all files by a prefix from one storage to another without any special treatment" | ||
|
||
// filesCmd represents the files command | ||
var filesCmd = &cobra.Command{ | ||
Use: "files prefix --source='source_storage' [--target='target_storage']", | ||
Short: filesShortDescription, | ||
Args: cobra.ExactArgs(1), | ||
Run: func(_ *cobra.Command, args []string) { | ||
transferFiles(args[0]) | ||
}, | ||
} | ||
|
||
func transferFiles(prefix string) { | ||
separateFileLister := transfer.NewRegularFileLister(prefix, transferOverwrite, int(transferMaxFiles)) | ||
|
||
cfg := &transfer.HandlerConfig{ | ||
FailOnFirstErr: transferFailFast, | ||
Concurrency: transferConcurrency, | ||
AppearanceChecks: transferAppearanceChecks, | ||
AppearanceChecksInterval: transferAppearanceChecksInterval, | ||
} | ||
|
||
handler, err := transfer.NewHandler(transferSourceStorage, targetStorage, separateFileLister, cfg) | ||
tracelog.ErrorLogger.FatalOnError(err) | ||
|
||
err = handler.Handle() | ||
tracelog.ErrorLogger.FatalOnError(err) | ||
} | ||
|
||
func init() { | ||
transferCmd.AddCommand(filesCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package st | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"github.com/wal-g/wal-g/utility" | ||
) | ||
|
||
const pgWALsShortDescription = "Moves all PostgreSQL WAL files from one storage to another" | ||
|
||
// pgWALsCmd represents the pg-wals command | ||
var pgWALsCmd = &cobra.Command{ | ||
Use: "pg-wals --source='source_storage' [--target='target_storage']", | ||
Short: pgWALsShortDescription, | ||
Args: cobra.NoArgs, | ||
Run: func(_ *cobra.Command, _ []string) { | ||
transferFiles(utility.WalPath) | ||
}, | ||
} | ||
|
||
func init() { | ||
transferCmd.AddCommand(pgWALsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.