Class: EyBackup::PostgresqlBackup
- Inherits:
-
MysqlBackup
- Object
- MysqlBackup
- EyBackup::PostgresqlBackup
- Defined in:
- lib/ey-backup/postgresql_backup.rb
Instance Method Summary collapse
Methods inherited from MysqlBackup
#cleanup, #download, #initialize, #list, #new_backup, #normalize_name
Constructor Details
This class inherits a constructor from EyBackup::MysqlBackup
Instance Method Details
#backup_database(database) ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/ey-backup/postgresql_backup.rb', line 3 def backup_database(database) posgrecmd = "PGPASSWORD='#{@dbpass}' pg_dump --clean --no-owner --no-privileges -U#{@dbuser} #{database} | gzip - > /mnt/tmp/#{database}.#{@tmpname}" if system(posgrecmd) AWS::S3::S3Object.store( "/#{@id}.#{database}/#{database}.#{@tmpname}", open("/mnt/tmp/#{database}.#{@tmpname}"), @bucket, :access => :private ) FileUtils.rm "/mnt/tmp/#{database}.#{@tmpname}" puts "successful backup: #{database}.#{@tmpname}" else raise "Unable to dump database#{database} wtf?" end end |
#restore(index) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/ey-backup/postgresql_backup.rb', line 19 def restore(index) name = download(index) db = name.split('.').first cmd = "gunzip -c #{name} | PGPASSWORD='#{@dbpass}' psql -U#{@dbuser} #{db}" if system(cmd) puts "successfully restored backup: #{name}" else puts "FAIL" end end |