class Freydis::Rsync
Public Class Methods
new(data)
click to toggle source
# File lib/freydis/rsync.rb, line 5 def initialize(data) @data = data @mountpoint = '/mnt/freydis' @exclude_paths = [ "/dev/*", "/proc/*", "/sys/*", "/tmp/*", "/run/*", "/mnt/*", "/media/*", "/home/*/.thumbnails/*", "/home/*/.cache/mozilla/*", "/home/*/.cache/chromium/*", "/home/*/.local/share/Trash/*", "/lost+found", ] @opts = "-aAXHvR" end
Public Instance Methods
backup()
click to toggle source
# File lib/freydis/rsync.rb, line 25 def backup add_config exil = @exclude_paths * "," save = @data[:paths] * " " @opts += " --delete" exec("rsync #{@opts} --exclude={#{exil}} #{save} #{@mountpoint}") end
restore()
click to toggle source
# File lib/freydis/rsync.rb, line 33 def restore exil = @exclude_paths * "," exec("rsync #{@opts} --exclude={#{exil}} #{@mountpoint} /") end
Private Instance Methods
add_config()
click to toggle source
# File lib/freydis/rsync.rb, line 40 def add_config if !@data[:paths].include?("#{ENV['HOME']}/.config/freydis") @data[:paths] << "#{ENV['HOME']}/.config/freydis" end end
exec(command)
click to toggle source
# File lib/freydis/rsync.rb, line 46 def exec(command) sudo = Process.uid != 0 ? 'sudo' : '' if !system("#{sudo} #{command}") raise StandardError, "[-] #{command}" end end