-
Notifications
You must be signed in to change notification settings - Fork 0
/
backup_mark.go
37 lines (33 loc) · 1.19 KB
/
backup_mark.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package pg
import (
"github.com/apecloud/dataprotection-wal-g/internal"
"github.com/apecloud/dataprotection-wal-g/internal/databases/postgres"
"github.com/spf13/cobra"
"github.com/wal-g/tracelog"
)
const (
BackupMarkShortDescription = "Marks a backup permanent or impermanent"
BackupMarkLongDescription = `Marks a backup permanent by default, or impermanent when flag is provided.
Permanent backups are prevented from being removed when running delete.`
ImpermanentDescription = "Marks a backup impermanent"
ImpermanentFlag = "impermanent"
)
var (
// backupMarkCmd represents the backupMark command
backupMarkCmd = &cobra.Command{
Use: "backup-mark backup_name",
Short: BackupMarkShortDescription,
Long: BackupMarkLongDescription,
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
uploader, err := internal.ConfigureUploader()
tracelog.ErrorLogger.FatalOnError(err)
internal.HandleBackupMark(uploader, args[0], !toImpermanent, postgres.NewGenericMetaInteractor())
},
}
toImpermanent = false
)
func init() {
backupMarkCmd.Flags().BoolVarP(&toImpermanent, ImpermanentFlag, "i", false, ImpermanentDescription)
Cmd.AddCommand(backupMarkCmd)
}