ruby-on-rails - digital ocean 服务器上的 psql db 转储到本地计算机

标签 ruby-on-rails ubuntu ruby-on-rails-4 hosting digital-ocean

我有一个在 digital ocean 上的 Ubuntu 上运行的应用程序,我想将数据库转储到我的本地计算机。这是一个 rails 应用程序。

我尝试运行以下命令,但出现 tcp/ip 错误:

ssh name@555.555.55.555 -C pg_dump  -U username | psql -U username

如何从 Ubuntu 到我的本地计算机进行数据库转储?

谢谢!!

最佳答案

您可以通过 ssh 连接到服务器,执行命令并保存到本地机器:

ssh user@machine "pg_dump -U user_name -h host -p port db_name" /
>> backup_file_on_your_local_machine.sql

更好的方法 - 尝试连接 pg_dump到远程主机:
pg_dump -U user_name -h host -p port db_name > dump_file

端口 通常是 5432 ,
主持人 - 本地主机

关于ruby-on-rails - digital ocean 服务器上的 psql db 转储到本地计算机,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43335120/

相关文章:

ruby-on-rails - ActiveRecord update_column : How to increase a record value depending on it's current value with just one query

ruby-on-rails - rails : configuring a form action's host using custom URL from settings

ruby-on-rails - Ruby Geocoder [Rails] - 如何遍历这个结果

linux - Apache 虚拟主机 - xxx.241.214.xxx :80 has no VirtualHosts

ruby-on-rails - 让 postgresql 在 cloud9 上工作

ruby-on-rails - rails 4 x paper_trail : track which attributes are updated and display their new value

ruby-on-rails - 重命名模型并更改对模型的所有引用后,对先前名称的引用仍然存在

ruby-on-rails - Rails 控制台是否重新加载初始值设定项?

linux - Eclipse Neon "Customize perspective"引发 "StackOverflowError"

python - 安装 Pyrouge 时出错