summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/byteback/backup_directory.rb9
-rw-r--r--lib/byteback/util.rb8
2 files changed, 15 insertions, 2 deletions
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