solid_backup 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 195e930fb3a17dcfc67ad285b28ccdcd4dd7bcb3fc659a7bc85c4f7e1ab915e6
4
- data.tar.gz: 1db537f2585f0548b73444e8f3661b811ea040a4ac306ed0a46eae3e9783c544
3
+ metadata.gz: dd198b0749b8c0ec8bbbf9371c95c95e3bf7967b3c76353b6bc8af310acbd160
4
+ data.tar.gz: 6c22706156961bcf44051d1023f6e5b2c50e4e02607a8b87f0dc6b774053963c
5
5
  SHA512:
6
- metadata.gz: ed4aba930756d2f3b32ad5571a5d84095497e9f63b3952f212350258608dc5f2ed0af100d19764d25d69146606560976d38630906bae695412a87c7b0b7befdb
7
- data.tar.gz: 4189596b8c2468d089306a01d11ce08d3f8dd42e036a0eeb96e2e4837205cd4987011ca8d4102b70708848766140021d32cc19619681ce9c800d270958fbfab7
6
+ metadata.gz: 2fdd803df8a709d66657b09bec4b49f27a94cc593a95ad27bb82daa1dd812391fb0e71a755124cdb3833c24fd10086b135b66f26665440c4a3d258c39110973d
7
+ data.tar.gz: 40649b13dfeacc3fc4db7c159ae017b0d2034e7075883ce4ad4bb0f1dc48b51ca4db9b62459898134477dede39c653590f095565aa587f4f3807cd52926aad03
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Solid Backup
2
2
 
3
+ ## 0.4.0
4
+
5
+ - Add backup compression support via the `compressor:` option; currently
6
+ `SolidBackup::Compressor::Gzip` is the only supported value.
7
+
3
8
  ## 0.3.0
4
9
 
5
10
  - `destination` is the directory where backup files will be placed, not a
data/README.md CHANGED
@@ -34,6 +34,8 @@ Modes other than `SolidBackup::Backup::None` take the following parameters:
34
34
  backup after the previous one finished.
35
35
  - `expiration` - backup expiration policy; expired backups are automatically
36
36
  removed.
37
+ - `compressor` - backup compression policy; `nil` be default which turns
38
+ compression off, but can be set to SolidBackup::Compressor::Gzip.
37
39
 
38
40
  Additionally, `SolidBackup::Backup::API` takes the following parameters:
39
41
 
@@ -65,7 +67,10 @@ SolidBackup.configure do |config|
65
67
  wait: 0.1,
66
68
 
67
69
  # Remove backups older than 30 days.
68
- expiration: SolidBackup::Expiration::Age.new(maximum: 30.days)
70
+ expiration: SolidBackup::Expiration::Age.new(maximum: 30.days),
71
+
72
+ # Compress backups using gzip.
73
+ compressor: SolidBackup::Compressor::Gzip
69
74
 
70
75
  # Don't back up the cache database.
71
76
  production.backup "cache", SolidBackup::Backup::None
@@ -79,7 +84,10 @@ SolidBackup.configure do |config|
79
84
  interval_in_minutes: 60,
80
85
 
81
86
  # Remove backups older than 12 hours.
82
- expiration: SolidBackup::Expiration::Age.new(maximum: 12.hours)
87
+ expiration: SolidBackup::Expiration::Age.new(maximum: 12.hours),
88
+
89
+ # Don't compress backups. This is the default setting.
90
+ compressor: nil
83
91
  end
84
92
  end
85
93
  ```
@@ -7,7 +7,7 @@
7
7
  # - destination and interval_in_minutes - to allow nil values
8
8
  class SolidBackup::Backup::None < SolidBackup::Backup
9
9
  def initialize(database:)
10
- super(database:, destination: nil, interval_in_minutes: 0, expiration: nil)
10
+ super(database:, destination: nil, interval_in_minutes: 0, expiration: nil, compressor: nil)
11
11
  end
12
12
 
13
13
  def tick
@@ -4,11 +4,12 @@ module SolidBackup
4
4
  class Backup
5
5
  attr_reader :database
6
6
 
7
- def initialize(database:, destination:, interval_in_minutes:, expiration:)
7
+ def initialize(database:, destination:, interval_in_minutes:, expiration:, compressor:)
8
8
  self.database = database
9
9
  self.destination = destination
10
10
  self.interval_in_minutes = interval_in_minutes
11
11
  self.expiration = expiration
12
+ self.compressor = compressor
12
13
 
13
14
  reset_countdown
14
15
  end
@@ -27,14 +28,20 @@ module SolidBackup
27
28
 
28
29
  private
29
30
 
30
- attr_accessor :countdown, :expiration
31
+ attr_accessor :countdown, :expiration, :compressor
31
32
  attr_writer :database
32
33
  attr_reader :destination, :interval_in_minutes
33
34
 
34
35
  def perform
35
36
  ActiveSupport::Notifications.instrument("backup.solid_backup", database:) do
36
37
  lock do
37
- do_perform(Time.now.utc.strftime((destination / file_name_pattern).to_s))
38
+ backup_path = Pathname(Time.now.utc.strftime((destination / file_name_pattern).to_s))
39
+ do_perform(backup_path)
40
+
41
+ next if compressor.nil?
42
+
43
+ compressor.compress(backup_path)
44
+ backup_path.unlink
38
45
  end
39
46
  end
40
47
  end
@@ -91,7 +98,7 @@ module SolidBackup
91
98
  end
92
99
 
93
100
  def file_name_pattern
94
- "#{database}_%Y%m%dT%H%M%S.sqlite3"
101
+ "#{database}_%Y%m%dT%H%M%S%Z.sqlite3"
95
102
  end
96
103
 
97
104
  delegate :with_connection, to: :connection_pool
@@ -0,0 +1,14 @@
1
+ module SolidBackup::Compressor
2
+ module Gzip
3
+ def self.compress(source_path)
4
+ target_path = "#{source_path}.gz"
5
+ source_path = Pathname(source_path)
6
+
7
+ Zlib::GzipWriter.open(target_path) do |gzip|
8
+ gzip.mtime = source_path.mtime
9
+ gzip.orig_name = source_path.basename.to_s
10
+ gzip.write(source_path.binread)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -11,7 +11,7 @@ module SolidBackup::Expiration
11
11
  end
12
12
 
13
13
  def select_expired(pathnames)
14
- threshold = maximum.ago
14
+ threshold = maximum.ago.utc
15
15
  pathnames.select do |pathname|
16
16
  timestamp = yield(pathname)
17
17
  timestamp && timestamp < threshold
@@ -18,6 +18,7 @@ module SolidBackup
18
18
  destination: "storage/backups",
19
19
  interval_in_minutes: 60,
20
20
  expiration: SolidBackup::Expiration::Age.new(maximum: 24.hours),
21
+ compressor: SolidBackup::Compressor::Gzip,
21
22
  step: 100,
22
23
  wait: 0.1
23
24
  CODE
@@ -1,3 +1,3 @@
1
1
  module SolidBackup
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/solid_backup.rb CHANGED
@@ -7,6 +7,7 @@ require "solid_backup/backup/vacuum_into"
7
7
  require "solid_backup/configuration"
8
8
  require "solid_backup/configuration/environment"
9
9
  require "solid_backup/expiration"
10
+ require "solid_backup/compressor"
10
11
  require "solid_backup/version"
11
12
  require "solid_backup/railtie"
12
13
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Greg Navis
@@ -108,6 +108,7 @@ files:
108
108
  - lib/solid_backup/backup/api.rb
109
109
  - lib/solid_backup/backup/none.rb
110
110
  - lib/solid_backup/backup/vacuum_into.rb
111
+ - lib/solid_backup/compressor.rb
111
112
  - lib/solid_backup/configuration.rb
112
113
  - lib/solid_backup/configuration/environment.rb
113
114
  - lib/solid_backup/expiration.rb
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  - !ruby/object:Gem::Version
136
137
  version: '0'
137
138
  requirements: []
138
- rubygems_version: 4.0.10
139
+ rubygems_version: 4.0.20
139
140
  specification_version: 4
140
141
  summary: Solid Backup provides simple backups for SQLite databases in Ruby on Rails
141
142
  apps.