如何自动将 Heroku pgbackups 发送到 S3
我们使用 Heroku 的 PG Backups,它非常棒 http://addons.heroku.com/pgbackups
我目前每天手动将备份下载到我的计算机,然后将其上传到我的 S3 帐户。有谁知道如何设置 cron 作业来自动创建备份(每天都可以)并将其直接发送到我的 S3 帐户?
We use Heroku's PG Backups which has been great http://addons.heroku.com/pgbackups
I'm currently manually downloading the backups everyday to my computer and then uploading it to my S3 account. Does anyone know how to setup a cron job to automatically create a backup (daily is fine) and send it directly to my S3 account?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我已经修补了 gem 以修复 B 七提到的系统调用。获取数据库参数的正则表达式已损坏,因为非共享数据库的新 DATABASE_URL 现在包含端口号。
https://github.com/mokolabs/heroku_s3_backup
如果您使用的是 Cedar 堆栈,则此补丁应该为你工作。但我在 Bamboo 上,由于与 pg_dump 版本冲突,它对我不起作用。 Postgres 在 Bamboo 上是 8.x 版本,因此 pg_dump 无法从新的非共享数据库转储数据,因为它们都在 Postgres 9.1 版本上运行。
如果我能够找到 Bamboo 堆栈的解决方法,我将在这里更新 gem 和我的评论。
I've patched the gem to fix the system call mentioned by B Seven. The regex which grabbed the database params was breaking because the new DATABASE_URL for non-shared databases now contains a port number.
https://github.com/mokolabs/heroku_s3_backup
If you're on the Cedar stack, then this patch should work for you. But I'm on Bamboo and it doesn't work for me because of a version conflict with pg_dump. Postgres is version 8.x on Bamboo, so pg_dump can't dump data from the new non-shared databases because they are all running on Postgres version 9.1.
If I'm able to find a workaround for the Bamboo stack, I will update the gem and my comment here.
如果将其添加到 lib/tasks 并运行 cron 插件,herkou 将运行以下命令:
If you add this to lib/tasks and have the cron addon running herkou will run this:
恕我直言,最简单快捷(10 分钟)的方法是配置 heroku-db -backup-s3 构建包。无需代码,只需添加构建包并设置一些环境变量和一个重新安排。
IMHO the easiest and fast (10 minutes) way is to configure heroku-db-backup-s3 buildpack. No code need, only adding the buildpack and setup some environment variables and one reschedule.