Class: Backup::Task
- Inherits:
-
Confo::Config
- Object
- Confo::Config
- Backup::Task
- Defined in:
- lib/backup-agent/task.rb
Instance Method Summary collapse
-
#initialize ⇒ Task
constructor
A new instance of Task.
Constructor Details
#initialize ⇒ Task
Returns a new instance of Task.
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 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 |
# File 'lib/backup-agent/task.rb', line 3 def initialize(*) set :mysql_user, 'root' set :mysql_password, 'root' set :mysql_host, 'localhost' set :mysql_databases, -> do `/usr/bin/env mysql #{get(:mysql_connect)} -e "SHOW DATABASES;"` .split("\n") .reject { |el| el =~ /Database|information_schema|mysql|performance_schema|test|phpmyadmin/ } end set :mysqldump_options, %w( --single-transaction --add-drop-table --add-locks --create-options --disable-keys --extended-insert --quick) set :mysql_connect, -> do pass = get(:mysql_password) pass_param = pass && !pass.empty? ? "-p#{pass}" : '' "-u #{get(:mysql_user)} #{pass_param} -h #{get(:mysql_host)}" end set :mongo_databases, -> do if `/usr/bin/env mongo --eval "db.getMongo().getDBNames()"` =~ /connecting to: (.*)/m $1.split(/[\n,]/).reject(&:empty?) else [] end end set :mongo_host, 'localhost' set :mongo_connect, -> { "-h #{get(:mongo_host)}" } set :directories, -> { Dir['/var/www/*'].each_with_object({}) do |el, memo| if Dir.exists?(File.join(el, 'current/public/uploads')) memo["Uploads #{File.basename(el)}"] = File.join(el, 'current/public/uploads') end end } set :files, {} set :days_to_keep_backups, 30 super end |