#!/usr/local/rvm/rubies/ruby-1.9.3-p0/bin/ruby #!/usr/bin/ruby require 'fileutils' # This script can be used to stop the backups as a pre-command # You will need to write the logic in the run() method # ID of the backup set in concern BACKUP_SET_ID = "13XXXXXXXXXXXX" USER_HOME="/Users/myhome" # If you want to print out the messages VERBOSE = true # Change this method to reflect when you want to stop the backup # Return true when you want to run the back and false when you want to stop it def run name = "/Volumes/share" return (is_present(name) and is_mounted(name)) end # Util functions def is_present(name) File.exists?(name) end def is_mounted(name) system("mount|grep #{name}") end # Loop of logic -- PLEASE DON'T TOUCH THIS UNLESS YOU KNOW WHAT YOU ARE DOING def print(*args) if VERBOSE args.each do |arg| puts arg end end end print "Start Script" if run print "Condition is satisfied", "Not executing the command" else print "Condition is not satisfied" command = "/usr/bin/touch #{USER_HOME}/.obm/ipc/BackupSet/#{BACKUP_SET_ID}/stop" print command output = %x[#{command}] if output.nil? or output.empty? print "Command Executed Successfully" else print output end end print "End script"