Class: Create
Overview
Creates a backup profile to be used by Backup
Instance Attribute Summary collapse
-
#db ⇒ Object
Returns the value of attribute db.
-
#db_host ⇒ Object
Returns the value of attribute db_host.
-
#db_pass ⇒ Object
Returns the value of attribute db_pass.
-
#db_port ⇒ Object
Returns the value of attribute db_port.
-
#db_user ⇒ Object
Returns the value of attribute db_user.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#tracker_host ⇒ Object
Returns the value of attribute tracker_host.
-
#tracker_port ⇒ Object
Returns the value of attribute tracker_port.
-
#workers ⇒ Object
Returns the value of attribute workers.
Instance Method Summary collapse
-
#initialize(o = {}) ⇒ Create
constructor
Run validations and create the backup profile.
-
#save_settings ⇒ Bool
Save the settings for the backup into a yaml file (settings.yaml) so that an incremental can be ran without so many parameters.
Methods included from Validations
#check_backup_path, #check_mogile_domain, #check_settings_file, #connect_sqlite, #create_sqlite_db, #migrate_sqlite, #mogile_db_connect, #mogile_tracker_connect
Constructor Details
#initialize(o = {}) ⇒ Create
Run validations and create the backup profile
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 |
# File 'lib/create.rb', line 8 def initialize(o={}) @db = o[:db] if o[:db] @db_host = o[:db_host] if o[:db_host] @db_port = Integer(o[:db_port]) if o[:db_port] @db_pass = o[:db_pass] if o[:db_pass] @db_user = o[:db_user] if o[:db_user] @domain = o[:domain] if o[:domain] @tracker_ip = o[:tracker_ip] if o[:tracker_ip] @tracker_port = o[:tracker_port] if o[:tracker_port] #If settings.yml exists then this is an existing backup and you cannot run a create on top of it raise 'Cannot run create on an existing backup. Try: mogbak backup #{$backup_path} to backup. If you want to change settings on this backup profile you will have to edit #{$backup_path}/settings.yml manually.' if check_settings_file(nil) check_backup_path create_sqlite_db connect_sqlite migrate_sqlite mogile_db_connect mogile_tracker_connect check_mogile_domain(@domain) #Save settings save_settings end |
Instance Attribute Details
#db ⇒ Object
Returns the value of attribute db.
3 4 5 |
# File 'lib/create.rb', line 3 def db @db end |
#db_host ⇒ Object
Returns the value of attribute db_host.
3 4 5 |
# File 'lib/create.rb', line 3 def db_host @db_host end |
#db_pass ⇒ Object
Returns the value of attribute db_pass.
3 4 5 |
# File 'lib/create.rb', line 3 def db_pass @db_pass end |
#db_port ⇒ Object
Returns the value of attribute db_port.
3 4 5 |
# File 'lib/create.rb', line 3 def db_port @db_port end |
#db_user ⇒ Object
Returns the value of attribute db_user.
3 4 5 |
# File 'lib/create.rb', line 3 def db_user @db_user end |
#domain ⇒ Object
Returns the value of attribute domain.
3 4 5 |
# File 'lib/create.rb', line 3 def domain @domain end |
#tracker_host ⇒ Object
Returns the value of attribute tracker_host.
3 4 5 |
# File 'lib/create.rb', line 3 def tracker_host @tracker_host end |
#tracker_port ⇒ Object
Returns the value of attribute tracker_port.
3 4 5 |
# File 'lib/create.rb', line 3 def tracker_port @tracker_port end |
#workers ⇒ Object
Returns the value of attribute workers.
3 4 5 |
# File 'lib/create.rb', line 3 def workers @workers end |
Instance Method Details
#save_settings ⇒ Bool
Save the settings for the backup into a yaml file (settings.yaml) so that an incremental can be ran without so many parameters
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/create.rb', line 36 def save_settings require ('yaml') settings = { 'db' => @db, 'db_host' => @db_host, 'db_port' => @db_port, 'db_pass' => @db_pass, 'db_user' => @db_user, 'domain' => @domain, 'tracker_ip' => @tracker_ip, 'tracker_port' => @tracker_port, 'backup_path' => $backup_path } File.open("#{$backup_path}/settings.yml", "w") do |file| file.write settings.to_yaml end true end |