bup 0.4.0 → 0.5.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: ad9ad97e6299973d7d4a1ccdcd262671f14a12ec2ceedd952b265450b09e0c52
4
- data.tar.gz: f73201e37284194441f64c990f2a278e0e1d07e3827cf8c416e03062a4692f71
3
+ metadata.gz: c9226e1ffb057342aaf45173d2ecaafc78537d19a25db5e25ae8275311e3c46f
4
+ data.tar.gz: 74a4207d1606adbca58e7f2650a01f3ae422a8c9c752832c1e684faf817fd6a8
5
5
  SHA512:
6
- metadata.gz: 0ff5725cd4472470b23af3c7b6c36c5b181c8da73234026b86c654fa40eca15ff6d41e7966aa830efa27f534a5c1fbf538f8e5cd30578621f99662c9250e09c2
7
- data.tar.gz: d8c496a3d4e64be4d6fc1484100767137fed12409611eade931431a6c7a45c6cb37c95d1a36f0b4f8a7d15dd2501a1f20ff0e1f6e39c8ce1206f59e645248676
6
+ metadata.gz: 6d0c35ab5eb84c7a1a68527fe49e28f1347f6c0e9cc38017aa160ff31f41046afba36674cf5ce42cf6c6f1e30b2bad0c4f62108b54734253a490c21d5e73c8b1
7
+ data.tar.gz: 835d1ec79c3c4fcd7b42d9632b4e8c649ee41cefcac949fd658d8874d50c25edd7b99768e461e230fe7d0b385997f4a8dd6772d2f4d8d4e6835d603da2f3e448
data/CHANGELOG.md CHANGED
@@ -1,10 +1,15 @@
1
1
  ## [Unreleased]
2
2
 
3
- ## [0.4.0]
3
+ ## [0.5.0] - 2021-11-13
4
+
5
+ - Allow for a history size of 0.
6
+ - Add default_profile setting.
7
+
8
+ ## [0.4.0] - 2021-11-13
4
9
 
5
10
  - Bug fix for empty post_cmds list.
6
11
 
7
- ## [0.3.0]
12
+ ## [0.3.0] - 2021-11-13
8
13
 
9
14
  - Communicate the backup file base name through the environment variable BUP_FILENAME.
10
15
  - Rubocop fixes or ignore files.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- bup (0.4.0)
4
+ bup (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -14,6 +14,7 @@ Create a file ~/.buprc with the default contents...
14
14
 
15
15
  ```yaml
16
16
  ---
17
+ default_profile: default
17
18
  profiles:
18
19
  default:
19
20
  description: Simple backup of critical files.
data/buprc CHANGED
@@ -1,4 +1,5 @@
1
1
  ---
2
+ default_profile: default
2
3
  profiles:
3
4
  default:
4
5
  description: Simple backup of critical files.
data/exe/bup CHANGED
@@ -6,6 +6,7 @@ require "optparse"
6
6
 
7
7
  configfile = File.join(ENV["HOME"], ".buprc")
8
8
  config = Bup::Config.new
9
+ profile = nil
9
10
 
10
11
  OptParse.new do |opt|
11
12
  opt.banner = "#{$PROGRAM_NAME} #{Bup::VERSION}"
@@ -15,7 +16,7 @@ OptParse.new do |opt|
15
16
  end
16
17
 
17
18
  opt.on("-p", "--profile=profile", String, "Profile name.") do |p|
18
- config.runtime["profile"] = p
19
+ profile = p
19
20
  end
20
21
 
21
22
  opt.on("-t", "--type=type", String, "Type of backup.") do |t|
@@ -29,6 +30,13 @@ end.parse!
29
30
 
30
31
  config.load(configfile) if File.exist?(configfile)
31
32
 
33
+ if profile
34
+ config.runtime["profile"] = profile
35
+ elsif config.config["default_profile"]
36
+ config.runtime["profile"] = config.config["default_profile"]
37
+ end
38
+
39
+
32
40
  case config.runtime["action"]
33
41
  when "list"
34
42
  config.config["profiles"].each do |key, profile|
data/lib/bup/tar.rb CHANGED
@@ -44,32 +44,46 @@ module Bup
44
44
 
45
45
  history = @config.profile(profile_name)["history"] || 0
46
46
 
47
- if type == "full" && history.positive?
47
+ if type == "full"
48
+ if history.positive?
49
+ prune_history(profile_name, destination, filename_base, history)
50
+ elsif history == 0
51
+ clear_history(profile_name, destination)
52
+ end
53
+ end
48
54
 
49
- oldest_kept_file = nil
55
+ filename
56
+ end
50
57
 
51
- # Keep some full backups and remove the others.
52
- # We capture the oldest full backup and get rid of preceeding incrementals.
53
- Dir["#{destination}/#{filename_base}*"].sort.reverse.each_with_index do |fullbackup, idx|
54
- if idx < history
55
- oldest_kept_file = fullbackup
56
- else
57
- File.delete(fullbackup)
58
- end
59
- end
58
+ def clear_history(profile_name, destination)
59
+ Dir["#{destination}/#{profile_name}*"].each do |backup|
60
+ File.delete(backup)
61
+ end
62
+ end
60
63
 
61
- # Remove all incremental files that are older than the oldest kept full backup.
62
- if oldest_kept_file
63
- remove_before = File.stat(oldest_kept_file).ctime
64
- Dir["#{destination}/#{profile_name}*"].each do |backupfile|
65
- File.delete(backupfile) if File.stat(backupfile).ctime < remove_before
66
- end
64
+ def prune_history(profile_name, destination, filename_base, history)
65
+ oldest_kept_file = nil
66
+
67
+ # Keep some full backups and remove the others.
68
+ # We capture the oldest full backup and get rid of preceeding incrementals.
69
+ Dir["#{destination}/#{filename_base}*"].sort.reverse.each_with_index do |fullbackup, idx|
70
+ if idx < history
71
+ oldest_kept_file = fullbackup
72
+ else
73
+ File.delete(fullbackup)
67
74
  end
68
75
  end
69
76
 
70
- filename
77
+ # Remove all incremental files that are older than the oldest kept full backup.
78
+ if oldest_kept_file
79
+ remove_before = File.stat(oldest_kept_file).ctime
80
+ Dir["#{destination}/#{profile_name}*"].each do |backupfile|
81
+ File.delete(backupfile) if File.stat(backupfile).ctime < remove_before
82
+ end
83
+ end
71
84
  end
72
85
 
86
+ # Run tar.
73
87
  def call(profile_name = nil)
74
88
  profile_name ||= @config.runtime["profile"]
75
89
  profile = @config.config["profiles"][profile_name]
@@ -106,6 +120,7 @@ module Bup
106
120
  end
107
121
  end
108
122
 
123
+ # Exec and run a command in a standard way.
109
124
  def run_cmd(*args)
110
125
  Open3.popen3(*args) do |stdin, stdout, stderr, wait_thr|
111
126
  stdin.close
data/lib/bup/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Bup
4
- VERSION = "0.4.0"
4
+ VERSION = "0.5.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Baskinger