Postgres Economy DB support - #4
Conversation
fac2e86 to
3087d81
Compare
The backup is already compressed, so compressing again makes little sense
3087d81 to
2ff7519
Compare
| when DEDICATED_KIND | ||
| PostgresBackupService.new(data: data, name: name, dry_run: @nctl.dry_run) | ||
| when ECONOMY_KIND | ||
| PostgresDatabaseBackupService.new(db_ref: db_ref, data: data, nctl_client: @nctl, name: name) |
There was a problem hiding this comment.
Extracted the logic that previously was inlined here into two services, one for managing dedicated dbs and one for the shared dbs
| def list(name) | ||
| backups = backup_service_for(name).backups | ||
| if backups.empty? | ||
| Output.warning("No backups found for '#{name}'") | ||
| return | ||
| end | ||
|
|
||
| fqdn = data.dig("status", "atProvider", "fqdn") | ||
| if fqdn.nil? || fqdn.empty? | ||
| Output.error("Database FQDN not found; cannot capture backup.") | ||
| exit 1 | ||
| rows = backups.map do |backup| | ||
| [format_time(backup["ModTime"]), format_size(backup["Size"]), backup["Name"]] | ||
| end | ||
|
|
||
| cmd = ["ssh", "dbadmin@#{fqdn}", "sudo nine-postgresql-backup"] | ||
| Output.command(cmd.join(" ")) | ||
| system(*cmd) unless @nctl.dry_run | ||
| Output.table(rows, headers: ["DATE", "SIZE", "NAME"]) | ||
| rescue Deploio::Error => e | ||
| Output.error(e.message) | ||
| exit 1 | ||
| end |
There was a problem hiding this comment.
Sneaky new feature: Implemented a list command for economy dbs as it's fairly cheap (we have to list the backups anyway).
Implementing the list for dedicated dbs and actually letting the user chose the backup they want to download is up for a new PR.
| def build_option_args | ||
| args = [] | ||
| args << "--dry-run" if options[:dry_run] | ||
| args << "--no-color" if options[:no_color] | ||
| args << "--app" << options[:app] if options[:app] | ||
| args << "--org" << options[:org] if options[:org] | ||
| args | ||
| end |
There was a problem hiding this comment.
Moved to shared_options
| args << "--app" << merged_options[:app] if merged_options[:app] | ||
| args << "--org" << merged_options[:org] if merged_options[:org] | ||
| args | ||
| end |
There was a problem hiding this comment.
So essentially, you can now have --dry-run everywhere
coorasse
left a comment
There was a problem hiding this comment.
I like the implementation but why do we need the "forwarded options"? I think you can access "parent_options" already
As we moved most of our databases to the economy tier, I now miss the
pg backups downloadcommand. This PR implements it as backups finally got implemented by Nine 🎉 . It works like this:rcloneDownload:
List: