@@ -23,12 +23,10 @@ import (
2323 "os/exec"
2424 "strconv"
2525
26- "github.com/blang/semver"
2726 "github.com/cloudnative-pg/machinery/pkg/execlog"
2827 "github.com/cloudnative-pg/machinery/pkg/log"
2928
3029 barmanApi "github.com/cloudnative-pg/barman-cloud/pkg/api"
31- barmanCapabilities "github.com/cloudnative-pg/barman-cloud/pkg/capabilities"
3230 barmanCatalog "github.com/cloudnative-pg/barman-cloud/pkg/catalog"
3331 barmanCommand "github.com/cloudnative-pg/barman-cloud/pkg/command"
3432 "github.com/cloudnative-pg/barman-cloud/pkg/utils"
@@ -37,17 +35,14 @@ import (
3735// Command represents a barman backup command
3836type Command struct {
3937 configuration * barmanApi.BarmanObjectStoreConfiguration
40- capabilities * barmanCapabilities.Capabilities
4138}
4239
4340// NewBackupCommand creates a new barman backup command
4441func NewBackupCommand (
4542 configuration * barmanApi.BarmanObjectStoreConfiguration ,
46- capabilities * barmanCapabilities.Capabilities ,
4743) * Command {
4844 return & Command {
4945 configuration : configuration ,
50- capabilities : capabilities ,
5146 }
5247}
5348
@@ -59,11 +54,6 @@ func (b *Command) GetDataConfiguration(
5954 return options , nil
6055 }
6156
62- if ! b .capabilities .HasCompression (b .configuration .Data .Compression ) {
63- return nil , fmt .Errorf ("%v compression is not supported in Barman %v" ,
64- b .configuration .Data .Compression , b .capabilities .Version )
65- }
66-
6757 if len (b .configuration .Data .Compression ) != 0 {
6858 options = append (
6959 options ,
@@ -99,14 +89,10 @@ func (b *Command) GetBarmanCloudBackupOptions(
9989 ctx context.Context ,
10090 backupName string ,
10191 serverName string ,
102- exec barmanCapabilities.LegacyExecutor ,
10392) ([]string , error ) {
10493 options := []string {
10594 "--user" , "postgres" ,
106- }
107-
108- if b .capabilities .ShouldExecuteBackupWithName (exec ) {
109- options = append (options , "--name" , backupName )
95+ "--name" , backupName ,
11096 }
11197
11298 options , err := b .GetDataConfiguration (options )
@@ -147,55 +133,28 @@ func (b *Command) GetExecutedBackupInfo(
147133 ctx context.Context ,
148134 backupName string ,
149135 serverName string ,
150- exec barmanCapabilities.LegacyExecutor ,
151136 env []string ,
152137) (* barmanCatalog.BarmanBackup , error ) {
153- if b .capabilities .ShouldExecuteBackupWithName (exec ) {
154- return barmanCommand .GetBackupByName (
155- ctx ,
156- backupName ,
157- serverName ,
158- b .configuration ,
159- env ,
160- )
161- }
162-
163- // we don't know the id or the name of the executed backup so it fetches the last executed barman backup.
164- // it could create issues in case of concurrent backups. It is a deprecated way of detecting the backup.
165- return barmanCommand .GetLatestBackup (
138+ return barmanCommand .GetBackupByName (
166139 ctx ,
140+ backupName ,
167141 serverName ,
168142 b .configuration ,
169143 env ,
170144 )
171145}
172146
173- // IsCompatible checks if barman can back up this version of PostgreSQL
174- func (b * Command ) IsCompatible (postgresVers semver.Version ) error {
175- switch {
176- case postgresVers .Major == 15 && b .capabilities .Version .Major < 3 :
177- return fmt .Errorf (
178- "PostgreSQL %d is not supported by Barman %d.x" ,
179- postgresVers .Major ,
180- b .capabilities .Version .Major ,
181- )
182- default :
183- return nil
184- }
185- }
186-
187147// Take takes a backup
188148func (b * Command ) Take (
189149 ctx context.Context ,
190150 backupName string ,
191151 serverName string ,
192152 env []string ,
193- legacyExecutor barmanCapabilities.LegacyExecutor ,
194153 backupTemporaryDirectory string ,
195154) error {
196155 log := log .FromContext (ctx )
197156
198- options , backupErr := b .GetBarmanCloudBackupOptions (ctx , backupName , serverName , legacyExecutor )
157+ options , backupErr := b .GetBarmanCloudBackupOptions (ctx , backupName , serverName )
199158 if backupErr != nil {
200159 log .Error (backupErr , "while getting barman-cloud-backup options" )
201160 return backupErr
@@ -204,10 +163,10 @@ func (b *Command) Take(
204163 // record the backup beginning
205164 log .Info ("Starting barman-cloud-backup" , "options" , options )
206165
207- cmd := exec .Command (barmanCapabilities .BarmanCloudBackup , options ... ) // #nosec G204
166+ cmd := exec .Command (utils .BarmanCloudBackup , options ... ) // #nosec G204
208167 cmd .Env = env
209168 cmd .Env = append (cmd .Env , "TMPDIR=" + backupTemporaryDirectory )
210- if err := execlog .RunStreaming (cmd , barmanCapabilities .BarmanCloudBackup ); err != nil {
169+ if err := execlog .RunStreaming (cmd , utils .BarmanCloudBackup ); err != nil {
211170 const badArgumentsErrorCode = "3"
212171 if err .Error () == badArgumentsErrorCode {
213172 descriptiveError := errors .New ("invalid arguments for barman-cloud-backup. " +
0 commit comments