Permalink
Browse files

added postgres dumpers

  • Loading branch information...
everzet committed Jun 8, 2010
1 parent 1d4c9c6 commit 1cf0f5716904087d3430f48bdd8ca972680fe49d
Showing with 12 additions and 0 deletions.
  1. +12 −0 lib/capifony.rb
View
@@ -217,6 +217,10 @@ def load_database_config(data, env = 'prod')
run "mysqldump -u#{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}" do |ch, stream, data|
puts data
end
+ when 'pgsql'
+ run "pg_dump -U #{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}" do |ch, stream, data|
+ puts data
+ end
end
`mkdir -p backups`
@@ -229,6 +233,8 @@ def load_database_config(data, env = 'prod')
case config['type']
when 'mysql'
`mysql -u#{config['user']} --password='#{config['pass']}' #{config['db']} < backups/#{sqlfile}`
+ when 'pgsql'
+ `psql -U #{config['user']} --password='#{config['pass']}' #{config['db']} < backups/#{sqlfile}`
end
`rm backups/#{sqlfile}`
end
@@ -244,6 +250,8 @@ def load_database_config(data, env = 'prod')
case config['type']
when 'mysql'
`mysqldump -u#{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}`
+ when 'pgsql'
+ `pg_dump -U #{config['user']} --password='#{config['pass']}' #{config['db']} | bzip2 -c > #{file}`
end
upload(file, "/tmp/#{filename}", :via => :scp)
@@ -258,6 +266,10 @@ def load_database_config(data, env = 'prod')
run "mysql -u#{config['user']} --password='#{config['pass']}' #{config['db']} < /tmp/#{sqlfile}" do |ch, stream, data|
puts data
end
+ when 'pgsql'
+ run "psql -U #{config['user']} --password='#{config['pass']}' #{config['db']} < /tmp/#{sqlfile}" do |ch, stream, data|
+ puts data
+ end
end
run "rm /tmp/#{filename}"

0 comments on commit 1cf0f57

Please sign in to comment.