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
62
63
64
65
66
67
68
69
70
|
# File 'lib/mysql_backup/install.rb', line 25
def install
begin
if File.exist?(CONF_FILE)
puts <<-WARN
#{CONF_FILE} already exists. Remove it and try again.
WARN
exit
end
user, password, host, dir = ask_for_options
File.open(CONF_FILE, 'w') do |file|
template = File.read(File.join(File.dirname(__FILE__), 'mysql_backup.yml.example'))
template.gsub!('USER', user)
template.gsub!('PASS', password)
template.gsub!('HOST', host)
template.gsub!('DIR', dir)
file << template
end
FileUtils.chmod(750, CONF_FILE)
puts <<-ERR
Configuration file #{CONF_FILE} written.
You can now backup all databases by running the following command:
$ mysql_backup
ERR
rescue Errno::EACCES => e
puts <<-ERR
You need to run this command with sudo or as root.
ERR
exit
end
end
|