summaryrefslogtreecommitdiff
path: root/lib/byteback
diff options
context:
space:
mode:
authorPatrick J Cherry <patrick@bytemark.co.uk>2016-11-09 09:30:12 +0000
committerPatrick J Cherry <patrick@bytemark.co.uk>2016-11-09 09:37:37 +0000
commit25f3947c16b57a9686500534e44423aab90b0bc7 (patch)
treef4c506e8f1e92db72c37b7c0794899d7bf4acb52 /lib/byteback
parented5ed3688a035f0caaea5a4fd3915e18a3576d78 (diff)
First pass at fixing btrfs path
This replaces the call to /sbin/btrfs with a method to find a btrfs program, which raises ENOENT if one cannot be found.
Diffstat (limited to 'lib/byteback')
-rw-r--r--lib/byteback/backup_directory.rb9
-rw-r--r--lib/byteback/util.rb7
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/byteback/backup_directory.rb b/lib/byteback/backup_directory.rb
index 14a55cf..53491ff 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..07d7056 100644
--- a/lib/byteback/util.rb
+++ b/lib/byteback/util.rb
@@ -66,5 +66,12 @@ module Byteback
pid2, status = Process.waitpid2(pid, 0)
status.exitstatus
end
+
+ def btrfs_bin
+ path = '/bin/btrfs'
+ path = '/sbin/btrfs' unless File.exists?(path)
+ path
+ end
+
end
end