Module: Backup::Environment::Unix::Commands

Defined in:
lib/backup/environment/unix.rb

Instance Method Summary collapse

Instance Method Details

#removeObject



73
74
75
76
# File 'lib/backup/environment/unix.rb', line 73

def remove
  puts "Removing Backup..\n"
  %x{ sudo rm -rf #{BACKUP_PATH} }
end

#resetObject



63
64
65
66
67
68
69
70
71
# File 'lib/backup/environment/unix.rb', line 63

def reset
  if File.directory?(BACKUP_PATH)
    remove
    setup
  else
    puts "Backup is not installed.\n"
    puts "Run the following command to install it:\n\nbackup --setup"
  end
end

#setupObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/backup/environment/unix.rb', line 21

def setup
  unless File.directory?(BACKUP_PATH)
    puts "Installing Backup in #{BACKUP_PATH}.."
    %x{ sudo mkdir -p #{File.join(BACKUP_PATH, 'config')} }
    %x{ sudo cp #{File.join(File.dirname(__FILE__), '..', '..', '..', 'setup', 'backup.sqlite3')} #{BACKUP_PATH} }
    %x{ sudo cp #{File.join(File.dirname(__FILE__), '..', '..', '..', 'setup', 'backup.rb')} #{File.join(BACKUP_PATH, 'config')} }
    puts <<-MESSAGE
      
  ==============================================================
  Backup has been set up!
  ==============================================================

  1: Set up some "Backup Settings" inside the configuration file!

    /opt/backup/config/backup.rb


  2: Run the backups!

    sudo backup --run [trigger]


  For a list of Backup commands:

    sudo backup --help
  

  For More Information:

    http://github.com/meskyanichi/backup

  ==============================================================
      
    MESSAGE
  else
    puts "\nBackup is already installed in #{BACKUP_PATH}..\n"
    puts "If you want to reset it, run:\n\nbackup --reset\n\n"
    puts "This will reinstall it."
    puts "Warning: All configuration will be lost!\n\n"
  end
end