ruby - 如何将公共(public)链接存储在备份变量中(使用 pgbackup :url) on heroku using the heroku-api. rb 文件

标签 ruby api heroku add-on

我在 Heroku 上有一个应用程序,我想将我在 Heroku 上的生产数据库备份到单独的云服务提供商站点上的备份文件存储库。为此,我需要从 heroku 获取公共(public) URL 进行备份,我只是不确定如何调用 api 来获取它。这是我想如何获得它的一些粗略的 sudo 代码,但显然语法来 self 的头脑/其他人的例子,所以它不是工作代码。

require 'heroku-api'

heroku = Heroku::API.new(:api_key => API_KEY)

> (if the backup file is too large, then your database is split into multiple backup files so I need to loop through each of the public URL's generated)

heroku.get_addons('my-heroku-app').pgbackup.url.each do |public_file|

current_url = public_file.url.link
(here is where I would use that link to copy the file to another server)

end

Heroku 提供了有关如何从命令行而不是 API 执行此操作的文档。这是他们网站上关于如何从命令行执行此操作的片段。

> Downloading a backup
> 
> You can create a publicly accessible backup URL with the pgbackups:url
> command. This is useful when migrating data between applications,
> upgrading starter tier plans, and exporting your data.
> 
> $ heroku pgbackups:url
> "http://s3.amazonaws.com/hkpgbackups/app1234567@heroku.com/b004.dump?AWSAccessKeyId=ABCD1234&Expires=1289261668&Signature=3mMBeKISewgEUDT%2FL5mRz4EYS4M%3D"
> By default the URL will reference the most recent backup. To access
> another backup pass the backup ID to the pgbackups:url command.

此外,他们在 github https://github.com/heroku/heroku.rb 上的文档中提供了一些帮助,但该站点上的示例还不足以让我了解如何实际使用此附加组件。

如有任何帮助,我们将不胜感激!谢谢!

最佳答案

因为它是一个单独的插件,所以它有自己的 api,并且不是 heroku-rb 的一部分。如果您想查看 CLI 调用了哪些 API,请查看此文件:https://github.com/heroku/heroku/blob/master/lib/heroku/client/pgbackups.rb

但是请注意,虽然您可以找出 API,但它没有记录在案,并且可以而且将会更改,恕不另行通知。这不是出于恶意,而是我们还没有花时间为 pgbackups 确定一个可靠的 api,我们会为支持它而感到自豪。

与此同时,尽管继续使用它,但要注意它。

关于ruby - 如何将公共(public)链接存储在备份变量中(使用 pgbackup :url) on heroku using the heroku-api. rb 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14991872/

相关文章:

java - Heroku mvn 找不到错误

javascript - Rails-找出JavaScript配置

ruby - 数组方程解释

arrays - 删除数组中第一个空格后的所有内容

api - 使用 RESTful API 进行客户端和服务器端验证

javascript - axios 授权 header 仅适用于获取请求

python - 部署 Django/Heroku 时 PySFTP 失败并显示 "No hostkey for host X found"

ruby - 在 Ruby 中规范化 XML

javascript - Rails 中 JSON/Javascript 解析的正确过程?

.net - .net core 3.1 web api 中的多个 get 方法