phusion-backup 1.0.0 → 1.0.1
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.
- data/bin/phusion-backup +34 -3
- data/phusion-backup.gemspec +1 -1
- data/resources/default-install-script.txt +1 -0
- metadata +3 -3
data/bin/phusion-backup
CHANGED
@@ -63,7 +63,7 @@ class Core
|
|
63
63
|
next if hostname =~ /^\./
|
64
64
|
fullname = "#{dir}/#{hostname}"
|
65
65
|
if File.directory?(fullname)
|
66
|
-
results << Server.new(hostname, fullname)
|
66
|
+
results << Server.new(hostname, File.expand_path(fullname))
|
67
67
|
end
|
68
68
|
end
|
69
69
|
end
|
@@ -71,7 +71,8 @@ class Core
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def find_server(hostname_or_dir)
|
74
|
-
|
74
|
+
fulldir = File.expand_path(hostname_or_dir)
|
75
|
+
return servers.find { |s| s.hostname == hostname_or_dir || s.dir == fulldir }
|
75
76
|
end
|
76
77
|
|
77
78
|
def generate(dir)
|
@@ -94,15 +95,45 @@ class Core
|
|
94
95
|
filename = create_globbing_filelist(server)
|
95
96
|
begin
|
96
97
|
sh!('rdiff-backup',
|
97
|
-
'-
|
98
|
+
'-v5',
|
99
|
+
'--print-statistics',
|
98
100
|
'--exclude-sockets',
|
99
101
|
'--include-globbing-filelist', filename,
|
100
102
|
"root@#{server.hostname}::/",
|
101
103
|
"#{server.dir}/data")
|
104
|
+
delete_old_backups(server)
|
102
105
|
ensure
|
103
106
|
File.unlink(filename)
|
104
107
|
end
|
105
108
|
end
|
109
|
+
|
110
|
+
def delete_old_backups(server)
|
111
|
+
return if !File.exist?(server.dir)
|
112
|
+
command = "rdiff-backup --list-increments --parsable-output \"#{server.dir}/data\""
|
113
|
+
increments = `#{command}`
|
114
|
+
if $?.exitstatus != 0
|
115
|
+
puts_error "The command `#{command}` failed."
|
116
|
+
raise CommandError
|
117
|
+
end
|
118
|
+
|
119
|
+
timestamps = []
|
120
|
+
increments.split("\n").each do |line|
|
121
|
+
if line =~ /^(\d+) directory$/
|
122
|
+
timestamps << $1.to_i
|
123
|
+
else
|
124
|
+
puts_error "The command `#{command}` returned an unrecognized output line: #{line.inspect}"
|
125
|
+
exit 1
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
if timestamps.size > 5
|
130
|
+
puts "<b>Deleting all but the most recent 5 backups...</b>"
|
131
|
+
timestamps.sort! { |a, b| b <=> a }
|
132
|
+
sh!("rdiff-backup", "--remove-older-than",
|
133
|
+
timestamps[4].to_s, "--force",
|
134
|
+
"#{server.dir}/data")
|
135
|
+
end
|
136
|
+
end
|
106
137
|
|
107
138
|
private
|
108
139
|
class CommandError < StandardError
|
data/phusion-backup.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: phusion-backup
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
9
|
+
- 1
|
10
|
+
version: 1.0.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Hongli Lai
|