From 9c51e8767da1005ed398a547f138b212460882a8 Mon Sep 17 00:00:00 2001 From: Dean Lofts Date: Sun, 1 Sep 2024 14:02:44 +1000 Subject: [PATCH] make gooder --- app/jobs/backup_database_job.rb | 14 +++++--------- .../backup_report_mailer/backup_completed.html.erb | 6 +----- 2 files changed, 6 insertions(+), 14 deletions(-) diff --git a/app/jobs/backup_database_job.rb b/app/jobs/backup_database_job.rb index e7f860c..eec630c 100644 --- a/app/jobs/backup_database_job.rb +++ b/app/jobs/backup_database_job.rb @@ -22,8 +22,8 @@ def perform # Calculate backup file size before deleting it backup_size = File.size?(compressed_file) - # Upload to DigitalOcean Spaces and get the signed URL - backup_url = upload_to_spaces(compressed_file) + # Upload to DigitalOcean Spaces (URL not needed anymore) + upload_to_spaces(compressed_file) # Optionally, delete the local backup files after upload File.delete(backup_file) if File.exist?(backup_file) @@ -31,8 +31,8 @@ def perform Rails.logger.info "BackupDatabaseJob: Backup created, compressed, and uploaded successfully: #{compressed_file}" - # Generate a report with the backup size - report = generate_backup_report(environment, compressed_file, "Success", backup_url, nil, backup_size) + # Generate a report without the URL + report = generate_backup_report(environment, compressed_file, "Success", nil, nil, backup_size) # Send an email with the report BackupReportMailer.backup_completed(report).deliver_now @@ -70,10 +70,6 @@ def upload_to_spaces(file_path) obj = S3_CLIENT.bucket(bucket_name).object("backups/#{file_name}") obj.upload_file(file_path) - - # Generate a signed URL that expires in 24 hours - signed_url = obj.presigned_url(:get, expires_in: 24 * 60 * 60) - - signed_url + end end diff --git a/app/views/backup_report_mailer/backup_completed.html.erb b/app/views/backup_report_mailer/backup_completed.html.erb index c0f9fb7..83d37cb 100644 --- a/app/views/backup_report_mailer/backup_completed.html.erb +++ b/app/views/backup_report_mailer/backup_completed.html.erb @@ -5,11 +5,7 @@

Environment: <%= @report[:environment] %>

Timestamp: <%= @report[:timestamp] %>

-<% if @report[:backup_url].present? %> -

Backup File: Download Backup

-<% else %> -

Backup File: <%= @report[:backup_file] %>

-<% end %> +

Backup File: The backup is available in your account. Please log in to access and download the backup.

Backup Size: <%= @report[:backup_size] %> bytes

Status: <%= @report[:status] %>