summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Elsworth <chris.elsworth@bytemark.co.uk>2017-01-31 11:47:52 +0000
committerChris Elsworth <chris.elsworth@bytemark.co.uk>2017-01-31 11:47:52 +0000
commit9703376afbebf06711bf5d1e874a59f806afd0f2 (patch)
tree896f657ab4edefa34d0e5661709b91ae6da7ee71
parent1943b5a11ed6615816bd476d16f2f319edfc772d (diff)
parent51ff72f7b458909071c4a42dbd25ab28ac16f3f8 (diff)
Merge branch '12-fix-btrfs-path' into 'master'
"byteback-server fails to work with backported btrfs-{tools progs}" Closes #12 See merge request !4
-rwxr-xr-xbin/byteback-prune2
-rwxr-xr-xbin/byteback-restore2
-rwxr-xr-xbin/byteback-setup-client-receive2
-rw-r--r--lib/byteback/backup_directory.rb9
-rw-r--r--lib/byteback/util.rb8
5 files changed, 18 insertions, 5 deletions
diff --git a/bin/byteback-prune b/bin/byteback-prune
index a91d003..a0cd0fb 100755
--- a/bin/byteback-prune
+++ b/bin/byteback-prune
@@ -147,4 +147,4 @@ if snapshots.empty?
end
info("Deleting #{snapshots.last.path}")
-log_system("/sbin/btrfs subvolume delete #{snapshots.last.path}")
+log_system("#{btrfs_bin} subvolume delete #{snapshots.last.path}")
diff --git a/bin/byteback-restore b/bin/byteback-restore
index 94babf8..2cd54c5 100755
--- a/bin/byteback-restore
+++ b/bin/byteback-restore
@@ -81,7 +81,7 @@ def restore_files(paths, snapshot, all)
end
args << "."
- puts args.join(" " ) if @verbose
+ puts args.join(" ") if @verbose
system(*args)
end
diff --git a/bin/byteback-setup-client-receive b/bin/byteback-setup-client-receive
index 3673b6a..528ccc9 100755
--- a/bin/byteback-setup-client-receive
+++ b/bin/byteback-setup-client-receive
@@ -32,7 +32,7 @@ Dir.chdir(ENV['HOME']) # don't know why we wouldn't be here
FileUtils.mkdir_p(@hostname)
error("Couldn't create btrfs subvolume") unless
- system("/sbin/btrfs subvolume create #{@hostname}/current")
+ system("#{btrfs_bin} subvolume create #{@hostname}/current")
FileUtils.mkdir_p('.ssh')
diff --git a/lib/byteback/backup_directory.rb b/lib/byteback/backup_directory.rb
index 89b0ae9..a39cf84 100644
--- a/lib/byteback/backup_directory.rb
+++ b/lib/byteback/backup_directory.rb
@@ -1,6 +1,11 @@
+require 'byteback/utils'
+
module Byteback
# Represents a particular timestamped backup directory
class Snapshot
+
+ include Byteback::Util
+
class << self
# What order to remove snapshots in to regain disk space?
#
@@ -111,11 +116,11 @@ module Byteback
end
def create!(from)
- system_no_error("/sbin/btrfs subvolume snapshot #{from} #{path}")
+ system_no_error("#{btrfs_bin} subvolume snapshot #{from} #{path}")
end
def delete!
- system_no_error("/sbin/btrfs subvolume delete #{path}")
+ system_no_error("#{btrfs_bin} subvolume delete #{path}")
end
# Returns the size of the given snapshot (runs du, may be slow)
diff --git a/lib/byteback/util.rb b/lib/byteback/util.rb
index 9a993d6..d70888b 100644
--- a/lib/byteback/util.rb
+++ b/lib/byteback/util.rb
@@ -66,5 +66,13 @@ module Byteback
pid2, status = Process.waitpid2(pid, 0)
status.exitstatus
end
+
+ def btrfs_bin
+ %w(/bin/btrfs /sbin/btrfs).each do |path|
+ return path if File.executable?(path)
+ end
+ raise Errno::ENOENT, 'btrfs'
+ end
+
end
end