bup 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -2
- data/Gemfile.lock +1 -1
- data/README.md +1 -0
- data/buprc +1 -0
- data/exe/bup +9 -1
- data/lib/bup/tar.rb +33 -18
- data/lib/bup/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9226e1ffb057342aaf45173d2ecaafc78537d19a25db5e25ae8275311e3c46f
|
4
|
+
data.tar.gz: 74a4207d1606adbca58e7f2650a01f3ae422a8c9c752832c1e684faf817fd6a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6d0c35ab5eb84c7a1a68527fe49e28f1347f6c0e9cc38017aa160ff31f41046afba36674cf5ce42cf6c6f1e30b2bad0c4f62108b54734253a490c21d5e73c8b1
|
7
|
+
data.tar.gz: 835d1ec79c3c4fcd7b42d9632b4e8c649ee41cefcac949fd658d8874d50c25edd7b99768e461e230fe7d0b385997f4a8dd6772d2f4d8d4e6835d603da2f3e448
|
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
-
## [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
data/README.md
CHANGED
data/buprc
CHANGED
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
|
-
|
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"
|
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
|
-
|
55
|
+
filename
|
56
|
+
end
|
50
57
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
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
|
-
|
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