Name of the database that needs to get dumped. To dump all databases, set this to `:all` or leave blank. username must be a PostgreSQL superuser to run `pg_dumpall`.
Tables to dump. This in only valid if `name` is specified. If none are given, the entire database will be dumped.
# File lib/backup/database/postgresql.rb, line 101 def connectivity_options return "--host='#{ socket }'" if socket opts = [] opts << "--host='#{ host }'" if host opts << "--port='#{ port }'" if port opts.join(' ') end
# File lib/backup/database/postgresql.rb, line 126 def dump_all? name == :all end
# File lib/backup/database/postgresql.rb, line 89 def password_option "PGPASSWORD='#{ password }' " if password end
Performs the mysqldump command and outputs the dump file in the dump_path using dump_filename.
<trigger>/databases/PostgreSQL[-<database_id>].sql[.gz]
# File lib/backup/database/postgresql.rb, line 51 def perform! super pipeline = Pipeline.new dump_ext = 'sql' pipeline << (dump_all? ? pgdumpall : pgdump) model.compressor.compress_with do |command, ext| pipeline << command dump_ext << ext end if model.compressor pipeline << "#{ utility(:cat) } > " + "'#{ File.join(dump_path, dump_filename) }.#{ dump_ext }'" pipeline.run if pipeline.success? log!(:finished) else raise Error, "Dump Failed!\n" + pipeline.error_messages end end
# File lib/backup/database/postgresql.rb, line 75 def pgdump "#{ password_option }" + "#{ sudo_option }" + "#{ utility(:pg_dump) } #{ username_option } #{ connectivity_options } " + "#{ user_options } #{ tables_to_dump } #{ tables_to_skip } #{ name }" end
# File lib/backup/database/postgresql.rb, line 82 def pgdumpall "#{ password_option }" + "#{ sudo_option }" + "#{ utility(:pg_dumpall) } #{ username_option } " + "#{ connectivity_options } #{ user_options }" end
# File lib/backup/database/postgresql.rb, line 93 def sudo_option "#{ utility(:sudo) } -n -u #{ sudo_user } " if sudo_user end
# File lib/backup/database/postgresql.rb, line 114 def tables_to_dump Array(only_tables).map do |table| "--table='#{ table }'" end.join(' ') end
# File lib/backup/database/postgresql.rb, line 120 def tables_to_skip Array(skip_tables).map do |table| "--exclude-table='#{ table }'" end.join(' ') end
Generated with the Darkfish Rdoc Generator 2.