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 +4 -4
- data/app/assets/stylesheets/ops_backups/application.css +3 -0
- data/app/controllers/ops_backups/backups_controller.rb +12 -0
- data/app/helpers/ops_backups/{application_helper.rb → backups_helper.rb} +1 -1
- data/app/models/ops_backups/backup.rb +12 -2
- data/app/views/layouts/ops_backups/application.html.erb +2 -2
- data/app/views/ops_backups/backups/index.html.erb +46 -0
- data/config/routes.rb +2 -0
- data/lib/ops_backups/version.rb +1 -1
- metadata +5 -4
- data/app/mailers/ops_backups/application_mailer.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d1cc538be0d6d4d093b408d7479a71bdb5b127d0d7ee4d34638c204ec1bff0d
|
4
|
+
data.tar.gz: eaf0ee80ac34ad175fce340d8e58c4291facbdfe95fc349b3332b2a3a9144b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 715640d119469926a5ec0babe36f82909c164d00964259be61c1df2912af8b7f23c61f53ad23718e96b17dcf4787fae0b47bced9fd0e0536f1c93e4d686cc717
|
7
|
+
data.tar.gz: bc0924697d406c27160cada6abcab128ef172c652f10f87f99cd3fbbfc67091eeef44e30e7a53e55a4ef0041c546b1d14d0713026577aea6a46de1cf556ed731
|
@@ -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,15 +1,25 @@
|
|
1
1
|
module OpsBackups
|
2
2
|
class Backup < ActiveRecord::Base
|
3
|
-
|
4
|
-
|
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
|
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
|
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
data/lib/ops_backups/version.rb
CHANGED
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.
|
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
|
+
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/
|
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
|