pg_s3_dumper 0.1.4 → 0.1.5

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
  SHA1:
3
- metadata.gz: c33d69433cb0de8e56d6dcb827b37127056e47a7
4
- data.tar.gz: 93a1e084a246a5e2e4cbd21b9471512e61018622
3
+ metadata.gz: 9a837802c2f2d926d2673ad6ff09f3e803bb141a
4
+ data.tar.gz: f0bccfbce6115d8834755ece91f40af1148a87d6
5
5
  SHA512:
6
- metadata.gz: 2d7ca920a30ad0acbf6894daa1d5bfe9e5cdbf247130053c88da345fe2630036fa21186b4f6b7a361b74809890d0bf9621e38cf8a8be5dcb086aa2e737f12825
7
- data.tar.gz: 80ce6b71c72e8bd1c4e2abe46fb557b705a88fd374c35940a6b752e49c05e78b81df75c573ac518d2462884ab0d3cad2e10d5646f8c60cd673bf9ecf18d24c95
6
+ metadata.gz: 2adb27f14f6861fc1f182ac28da7a1c85bc2a7964bf1bd5943da93ea7ae8bd2ca2889a1a0e5daa7369df01a5127da16ab600fcc6ca8aef701cdcf1d72d5e8963
7
+ data.tar.gz: d157714a3d23441a2622b825c2c0171a89bc4d69869ff3a3be91e738660a3aa48d02bfbcee30744344f8992e73a0c64f9f87e5a667b7dc3fffb97956055f8d25
@@ -26,10 +26,26 @@ class Backup
26
26
  ts.strftime('%F') == date.strftime('%F')
27
27
  end
28
28
 
29
+ def on_week?(date)
30
+ ts.strftime('%Y-%U') == date.strftime('%Y-%U')
31
+ end
32
+
33
+ def on_month?(date)
34
+ ts.strftime('%Y-%m') == date.strftime('%Y-%m')
35
+ end
36
+
29
37
  def keep_on_day(date)
30
38
  @keep = true if on_day?(date)
31
39
  end
32
40
 
41
+ def keep_on_week(date)
42
+ @keep = true if on_week?(date)
43
+ end
44
+
45
+ def keep_on_month(date)
46
+ @keep = true if on_month?(date)
47
+ end
48
+
33
49
  def prune
34
50
  if keep
35
51
  puts "Keeping backup: #{self}"
@@ -77,12 +77,7 @@ module PgS3Dumper
77
77
  # Keep daily backups for one week
78
78
  # Keep weekly backups for one month
79
79
  # Keep monthly backups for one year
80
- days =
81
- 7.times.map{|i| i.days.ago} +
82
- 4.times.map{|i| i.weeks.ago} +
83
- 12.times.map{|i| i.months.ago}
84
-
85
- days.each do |ts|
80
+ 7.times.map{|i| i.days.ago}.each do |ts|
86
81
  backups.each do |b|
87
82
  b.keep_on_day(ts)
88
83
  # We kept one backup on day ts, go to next day
@@ -90,6 +85,23 @@ module PgS3Dumper
90
85
  end
91
86
  end
92
87
 
88
+ 4.times.map{|i| i.weeks.ago}.each do |ts|
89
+ backups.each do |b|
90
+ b.keep_on_week(ts)
91
+ # We kept one backup on day ts, go to next day
92
+ break if b.keep
93
+ end
94
+ end
95
+
96
+ 12.times.map{|i| i.months.ago}.each do |ts|
97
+ backups.each do |b|
98
+ b.keep_on_month(ts)
99
+ # We kept one backup on day ts, go to next day
100
+ break if b.keep
101
+ end
102
+ end
103
+
104
+
93
105
  # Keep all backups for today
94
106
  backups.each do |b|
95
107
  b.keep_on_day(Date.today)
@@ -1,3 +1,3 @@
1
1
  module PgS3Dumper
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pg_s3_dumper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Goy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-03-16 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.4.5
112
+ rubygems_version: 2.4.5.1
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: Simple tool to dump postgresql database to an S3 bucket.