ops_backups 0.1.9 → 0.1.11
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/ops_backups/backup.rb +26 -34
- data/lib/ops_backups/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2fef2adc42b4749261dd1a0eb29142b0e55c84dd0465a519bdfdea0e3b86314
|
4
|
+
data.tar.gz: 4bf5d15d8584abfb624fc8071da8cb5afa578830e1bc4b8754b8e716692e67d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e70cc33d5f7d23e4f9cff8b22b0a6bcaa32d0830d4ea232c5d3e41db2f9adaca62ad484423c96ffbc9ec85d38fb2202094f3ff55c28b5a24c29c320a4a4caf3
|
7
|
+
data.tar.gz: 277e00a4449260ff40a4558df7bf7cd624e20a73ca72fe696d7bebd257529bbf2b175e813351401e0756d6f135ad2646b1139bdc0f35e68cf2e49a747247d55d
|
@@ -10,14 +10,6 @@ module OpsBackups
|
|
10
10
|
[ "created_at", "id", "name", "new_id", "tag", "updated_at" ]
|
11
11
|
end
|
12
12
|
|
13
|
-
def self.test
|
14
|
-
"self.test"
|
15
|
-
end
|
16
|
-
|
17
|
-
def hoho
|
18
|
-
"hihi"
|
19
|
-
end
|
20
|
-
|
21
13
|
def db_pg_backup(tag: nil, exclude_tables: [])
|
22
14
|
db_url = ENV["DATABASE_URL"]
|
23
15
|
tag ||= exclude_tables.empty? ? "db_pg_full" : "db_pg_partial" # if tag.empty?
|
@@ -48,36 +40,36 @@ module OpsBackups
|
|
48
40
|
end
|
49
41
|
end
|
50
42
|
end
|
51
|
-
end
|
52
43
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
44
|
+
# Keep all the backups of the last day
|
45
|
+
# Keep the last backup of each day in the last week (except the last day)
|
46
|
+
# Keep the last backup of each week in the last month (except the last week)
|
47
|
+
# Keep the last backup of each month before the last month
|
48
|
+
def self.retain_tiered_cleanup_policy(tag: "")
|
49
|
+
week = where(created_at: 1.week.ago..1.day.ago)
|
50
|
+
.group_by { |b| b.created_at.to_date }
|
51
|
+
month = where(created_at: 1.month.ago..1.week.ago)
|
52
|
+
.group_by { |b| b.created_at.beginning_of_week }
|
53
|
+
older = where(created_at: 1.year.ago..1.month.ago)
|
54
|
+
.group_by { |b| b.created_at.beginning_of_month }
|
64
55
|
|
65
|
-
|
56
|
+
backups = week.merge(month).merge(older)
|
66
57
|
|
67
|
-
|
68
|
-
|
69
|
-
|
58
|
+
ids = backups.flat_map do |_, group|
|
59
|
+
group.sort_by(&:created_at).reverse.drop(1).pluck(:id)
|
60
|
+
end
|
70
61
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
62
|
+
records = where(id: ids)
|
63
|
+
records = records.where(tag: tag) if tag.present?
|
64
|
+
records.destroy_all
|
65
|
+
end
|
75
66
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
67
|
+
# Keep the last 14 backups
|
68
|
+
def self.retain_last_limit_cleanup_policy(limit: 14, tag: "")
|
69
|
+
records = all
|
70
|
+
records = records.where(tag: tag) if tag.present?
|
71
|
+
records = records.order(updated_at: :desc).offset(limit)
|
72
|
+
records.destroy_all
|
73
|
+
end
|
82
74
|
end
|
83
75
|
end
|
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.11
|
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-
|
11
|
+
date: 2024-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|