ops_backups 0.1.11 → 0.1.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2fef2adc42b4749261dd1a0eb29142b0e55c84dd0465a519bdfdea0e3b86314
4
- data.tar.gz: 4bf5d15d8584abfb624fc8071da8cb5afa578830e1bc4b8754b8e716692e67d6
3
+ metadata.gz: 7d1cc538be0d6d4d093b408d7479a71bdb5b127d0d7ee4d34638c204ec1bff0d
4
+ data.tar.gz: eaf0ee80ac34ad175fce340d8e58c4291facbdfe95fc349b3332b2a3a9144b53
5
5
  SHA512:
6
- metadata.gz: 7e70cc33d5f7d23e4f9cff8b22b0a6bcaa32d0830d4ea232c5d3e41db2f9adaca62ad484423c96ffbc9ec85d38fb2202094f3ff55c28b5a24c29c320a4a4caf3
7
- data.tar.gz: 277e00a4449260ff40a4558df7bf7cd624e20a73ca72fe696d7bebd257529bbf2b175e813351401e0756d6f135ad2646b1139bdc0f35e68cf2e49a747247d55d
6
+ metadata.gz: 715640d119469926a5ec0babe36f82909c164d00964259be61c1df2912af8b7f23c61f53ad23718e96b17dcf4787fae0b47bced9fd0e0536f1c93e4d686cc717
7
+ data.tar.gz: bc0924697d406c27160cada6abcab128ef172c652f10f87f99cd3fbbfc67091eeef44e30e7a53e55a4ef0041c546b1d14d0713026577aea6a46de1cf556ed731
@@ -13,3 +13,6 @@
13
13
  *= require_tree .
14
14
  *= require_self
15
15
  */
16
+ html {
17
+ font-family: 'Courier New', Courier, monospace;
18
+ }
@@ -0,0 +1,12 @@
1
+ module OpsBackups
2
+ class BackupsController < ApplicationController
3
+ def index
4
+ @backups = OpsBackups::Backup.limit(20)
5
+ end
6
+
7
+ def download
8
+ backup = OpsBackups::Backup.find(params[:id])
9
+ redirect_to backup.backup_file.url(disposition: :attachment), allow_other_host: true
10
+ end
11
+ end
12
+ end
@@ -1,4 +1,4 @@
1
1
  module OpsBackups
2
- module ApplicationHelper
2
+ module BackupsHelper
3
3
  end
4
4
  end
@@ -1,15 +1,25 @@
1
1
  module OpsBackups
2
2
  class Backup < ActiveRecord::Base
3
- # has_one_attached :backup_file, service: :backup_storage
4
- has_one_attached :backup_file, service: :backups
3
+ include ActionView::Helpers::NumberHelper
4
+
5
5
  self.table_name = "ops_backups"
6
6
 
7
+ has_one_attached :backup_file, service: :backups
8
+
7
9
  default_scope { order(updated_at: :desc) }
8
10
 
9
11
  def self.ransackable_attributes(auth_object = nil)
10
12
  [ "created_at", "id", "name", "new_id", "tag", "updated_at" ]
11
13
  end
12
14
 
15
+ def size
16
+ backup_file.attached? ? number_to_human_size(backup_file.byte_size) : "N/A"
17
+ end
18
+
19
+ def duration
20
+ Time.at((updated_at - created_at)).utc.strftime("%H:%M:%S")
21
+ end
22
+
13
23
  def db_pg_backup(tag: nil, exclude_tables: [])
14
24
  db_url = ENV["DATABASE_URL"]
15
25
  tag ||= exclude_tables.empty? ? "db_pg_full" : "db_pg_partial" # if tag.empty?
@@ -1,13 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Ops backups</title>
4
+ <title>Ops Backups</title>
5
5
  <%= csrf_meta_tags %>
6
6
  <%= csp_meta_tag %>
7
7
 
8
8
  <%= yield :head %>
9
9
 
10
- <%= stylesheet_link_tag "ops_backups/application", media: "all" %>
10
+ <%= stylesheet_link_tag "ops_backups/application", media: "all" %>
11
11
  </head>
12
12
  <body>
13
13
 
@@ -0,0 +1,46 @@
1
+ <style>
2
+ ops-backups {
3
+ display: flex;
4
+ padding: 1em;
5
+ /* flex column */
6
+ flex-direction: column;
7
+ & ops-backup {
8
+ display: grid;
9
+ grid-template-columns: 1fr 1fr 10em 10em 18em 3em;
10
+ padding: 0.25em;
11
+ & ops-backup-size,
12
+ ops-backup-duration,
13
+ ops-backup-created_at,
14
+ ops-backup-download {
15
+ text-align: right;
16
+ }
17
+ }
18
+ & ops-backup.header {
19
+ font-weight: bold;
20
+ }
21
+ }
22
+ </style>
23
+ <h1>Backups</h1>
24
+ <ops-backups>
25
+ <ops-backup class="header">
26
+ <ops-backup-name>Name</ops-backup-name>
27
+ <ops-backup-tag>Tag</ops-backup-tag>
28
+ <ops-backup-size>Size</ops-backup-size>
29
+ <ops-backup-duration>Duration</ops-backup-duration>
30
+ <ops-backup-created_at>Created At</ops-backup-created_at>
31
+ </ops-backup>
32
+ <% @backups.each do |backup| %>
33
+ <ops-backup>
34
+ <ops-backup-name><%= backup.name %></ops-backup-name>
35
+ <ops-backup-tag><%= backup.name %></ops-backup-tag>
36
+ <ops-backup-size><%= backup.size %></ops-backup-size>
37
+ <ops-backup-duration><%= backup.duration %></ops-backup-duration>
38
+ <ops-backup-created_at><%= backup.created_at %></ops-backup-created_at>
39
+ <ops-backup-download>
40
+ <% if backup.backup_file.attached? %>
41
+ <a href="<%= download_backup_path(backup) %>" download>📎</a>
42
+ <% end %>
43
+ </ops-backup-download>
44
+ </ops-backup>
45
+ <% end %>
46
+ </ops-backups>
data/config/routes.rb CHANGED
@@ -1,2 +1,4 @@
1
1
  OpsBackups::Engine.routes.draw do
2
+ get 'backups', to: 'backups#index'
3
+ get 'backups/:id/download', to: 'backups#download', as: 'download_backup'
2
4
  end
@@ -1,3 +1,3 @@
1
1
  module OpsBackups
2
- VERSION = "0.1.11"
2
+ VERSION = "0.1.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ops_backups
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.11
4
+ version: 0.1.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koen Handekyn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-11-28 00:00:00.000000000 Z
11
+ date: 2024-12-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,15 +38,16 @@ files:
38
38
  - Rakefile
39
39
  - app/assets/stylesheets/ops_backups/application.css
40
40
  - app/controllers/ops_backups/application_controller.rb
41
- - app/helpers/ops_backups/application_helper.rb
41
+ - app/controllers/ops_backups/backups_controller.rb
42
+ - app/helpers/ops_backups/backups_helper.rb
42
43
  - app/jobs/ops_backups/application_job.rb
43
44
  - app/jobs/ops_backups/backup_db_job.rb
44
45
  - app/jobs/ops_backups/cleanup_limit_job.rb
45
46
  - app/jobs/ops_backups/cleanup_tiered_job.rb
46
- - app/mailers/ops_backups/application_mailer.rb
47
47
  - app/models/ops_backups/application_record.rb
48
48
  - app/models/ops_backups/backup.rb
49
49
  - app/views/layouts/ops_backups/application.html.erb
50
+ - app/views/ops_backups/backups/index.html.erb
50
51
  - bin/pgdb
51
52
  - bin/pgdb.sh
52
53
  - config/locales/en.yml
@@ -1,6 +0,0 @@
1
- module OpsBackups
2
- class ApplicationMailer < ActionMailer::Base
3
- default from: "from@example.com"
4
- layout "mailer"
5
- end
6
- end