Skip to content

Commit

Permalink
added postgres dumpers
Browse files Browse the repository at this point in the history
  • Loading branch information
everzet committed Jun 8, 2010
1 parent 1d4c9c6 commit 1cf0f57
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/capifony.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -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}"
Expand Down

0 comments on commit 1cf0f57

Please sign in to comment.