Class: Techinform::BackupCommand
- Inherits:
-
Thor
- Object
- Thor
- Techinform::BackupCommand
- Defined in:
- lib/techinform/backup.rb
Instance Method Summary collapse
- #etc ⇒ Object
- #files(files_backup = '/etc') ⇒ Object
- #mysql(dbnames) ⇒ Object
- #mysql_list ⇒ Object
- #pg(dbnames) ⇒ Object
- #pg_list ⇒ Object
- #sync(server, type, ipaddr) ⇒ Object
Instance Method Details
#etc ⇒ Object
44 45 46 47 |
# File 'lib/techinform/backup.rb', line 44 def etc require_relative '../../lib/backup/files_backup' FilesBackup.new('/etc').run end |
#files(files_backup = '/etc') ⇒ Object
38 39 40 41 |
# File 'lib/techinform/backup.rb', line 38 def files(files_backup='/etc') require_relative '../../lib/backup/files_backup' FilesBackup.new(files_backup).run end |
#mysql(dbnames) ⇒ Object
10 11 12 13 14 |
# File 'lib/techinform/backup.rb', line 10 def mysql(dbnames) (dbnames == 'all' ? mysql_list : dbnames.split(',')).each do |db| MysqlBackup.new(database: db).run end end |
#mysql_list ⇒ Object
17 18 19 20 21 |
# File 'lib/techinform/backup.rb', line 17 def mysql_list dbs = MysqlBackup.new.db_list puts "Available mysql databases: #{dbs.join(', ')}" dbs end |
#pg(dbnames) ⇒ Object
24 25 26 27 28 |
# File 'lib/techinform/backup.rb', line 24 def pg(dbnames) (dbnames == 'all' ? pg_list : dbnames.split(',')).each do |db| PostgreBackup.new(database: db).run end end |
#pg_list ⇒ Object
31 32 33 34 35 |
# File 'lib/techinform/backup.rb', line 31 def pg_list dbs = PostgreBackup.new.db_list puts "Available postgres databases: #{dbs.join(', ')}" dbs end |
#sync(server, type, ipaddr) ⇒ Object
51 52 53 54 55 |
# File 'lib/techinform/backup.rb', line 51 def sync(server, type, ipaddr) location = Techinform.backups_syncing_location(server, type) `mkdir -p #{location}` system("rsync -avz #{'--delete' if [:delete]} #{"--exclude-from=#{"#{File.dirname(__FILE__)}/sync/rails_exclude_files"}" if type == 'rails'} backup@#{ipaddr}::#{type} #{location}") end |