Skip to content

Conversation

@ndarilek
Copy link
Contributor

Change Summary

  • Adds a fly pg backup config subcommand with ability to show and update backup-related configuration values
  • Adds and refactors to helpers to run commands on Postgres machines or the cluster leader
nolan@nolan-fly:~/flyctl$ go run . pg backup config help                                                                
Manage backup configuration                                                                                             
                                                                                                                        
Usage:                                                                                                                  
  fly postgres backup config [command]                                                                                  
                                                                                                                        
Available Commands:                                                                                                     
  show        Show backup configuration                                                                                 
  update      Update backup configuration                                                                               
                                                                                                                        
Flags:                                                                                                                  
  -h, --help   help for config                                                                                          
                                                                                                                        
Global Flags:                                                                                                           
  -t, --access-token string   Fly API Access Token                                                                      
      --debug                 Print additional logs and traces                                                          
      --verbose               Verbose output                                                                            
                                                                                                                        
Use "fly postgres backup config [command] --help" for more information about a command.                                 
nolan@nolan-fly:~/flyctl$ go run . pg backup config show -a nolan-pg                                                    
  ArchiveTimeout = 60s                                                                                                  
  RecoveryWindow = 7d                                                                                                   
  FullBackupFrequency = 24h                                                                                             
  MinimumRedundancy = 3                                                                                                 
nolan@nolan-fly:~/flyctl$ go run . pg backup config update -a nolan-pg --minimum-redundancy foo                         
Exit code: 1                                                                                                            
error updating configuration: invalid value for minimum_redundancy: foo                                                 
nolan@nolan-fly:~/flyctl$ go run . pg backup config update -a nolan-pg --minimum-redundancy 5                           
Updated                                                                                                                 
A restart is required for these changes to take effect. Run `fly app restart -a nolan-pg` to restart.)nolan@nolan-fly:~/flyctl$ go run . pg backup config show -a nolan-pg                                                                      
  ArchiveTimeout = 60s                                                                                                  
  RecoveryWindow = 7d                                                                                                   
  FullBackupFrequency = 24h                                                                                             
  MinimumRedundancy = 5                                                                                                 

Related to: fly-apps/postgres-flex#244


Documentation

  • Fresh Produce
  • In superfly/docs, or asked for help from docs team
  • n/a

@ndarilek ndarilek marked this pull request as draft July 17, 2024 19:38
@ndarilek ndarilek marked this pull request as ready for review July 22, 2024 15:23
return hasRequiredVersionOnMachines(appName, machines, "", "0.0.53", "")
}

func hasRequiredVersionForBackupConfig(appName string, machines []*fly.Machine) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fine, but unnecessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not? Do we not want to block on versions like v0.0.53 with backup support but not backup config support? Happy to remove it but the UX when someone runs fly pg backup config wouldn't clarify how they fix it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, sorry, I should have clarified. The version check is necessary, but abstracting it into a separate function isn't, since it's just issuing a return.

}

func hasRequiredVersion(appName string, machines []*fly.Machine) error {
func hasRequiredVersionForBackup(appName string, machines []*fly.Machine) error {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we do the same thing here that we did below? Define the version as a constant and just reuse hasRequiredVersiononMachines ?

Copy link
Contributor

@davissp14 davissp14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment, but once that is fixed feel free to merge!

Copy link
Contributor

@davissp14 davissp14 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@ndarilek ndarilek merged commit 10e2b90 into master Jul 29, 2024
@ndarilek ndarilek deleted the pg-backup-config branch July 29, 2024 18:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants