Class: BRDB::RestoreDatabase
- Inherits:
-
Object
- Object
- BRDB::RestoreDatabase
- Defined in:
- lib/brdb.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ RestoreDatabase
constructor
A new instance of RestoreDatabase.
- #perform ⇒ Object
Constructor Details
#initialize ⇒ RestoreDatabase
Returns a new instance of RestoreDatabase.
5 6 7 |
# File 'lib/brdb.rb', line 5 def initialize @backups_dir = "#{ENV['HOME']}/db_backups/" end |
Class Method Details
.run ⇒ Object
9 10 11 |
# File 'lib/brdb.rb', line 9 def self.run self.new.perform end |
Instance Method Details
#perform ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/brdb.rb', line 13 def perform return unless dbname return unless backup_filename print "database: #{dbname}\nbackup: #{backup_filename}\n perform restore?\n(y/n)" x = $stdin.gets.chomp! if x == 'y' puts 'dropping db...' `RAILS_ENV=development bundle exec rake db:drop development` puts 'creating db...' `createdb #{dbname}` puts "restoring db from #{backup_filename}" `psql #{dbname} < #{backups_dir}#{backup_filename}` else puts 'aborted' end end |