我在DigitalOcean上使用Dokku运行Rails应用程序,并使用Rails backup gem定期进行数据库备份。最近我将应用程序从一个Droplet移动到另一个droplet(更改了区域),然后备份无法连接到DB。
备份模型(/root/Backup/models/oktob_database_backup.rb
)
Model.new(:oktob_database_backup, 'Oktob Production Database Backup') do
##
# PostgreSQL [Database]
#
database PostgreSQL do |db|
db.name = ENV['DATABASE_NAME']
db.username = ENV['DATABASE_USERNAME']
db.password = ENV['DATABASE_PASSWORD']
db.host = ENV['DATABASE_HOST']
db.port = ENV['DATABASE_PORT']
end
##
# Amazon Simple Storage Service [Storage]
#
store_with S3 do |s3|
# AWS Credentials
s3.access_key_id = ENV['AWS_ACCESS_KEY_ID']
s3.secret_access_key = ENV['AWS_SECRET_ACCESS_KEY']
s3.region = "us-west-2"
s3.bucket = ENV['AWS_DATABASE_BACKUP_BUCKET_NAME']
s3.path = "/"
end
##
# Gzip [Compressor]
#
compress_with Gzip
##
# Mail [Notifier]
#
# The default delivery method for Mail Notifiers is 'SMTP'.
# See the documentation for other delivery options.
#
notify_by Mail do |mail|
mail.on_success = true
mail.on_warning = true
mail.on_failure = true
mail.from = ENV['EMAIL_ADDRESS']
mail.to = ENV['EMAIL_ADDRESS']
mail.address = "smtp.gmail.com"
mail.port = 587
mail.domain = "oktob.io"
mail.user_name = ENV['SMTP_USERNAME']
mail.password = ENV['SMTP_PASSWORD']
mail.authentication = "plain"
mail.encryption = :starttls
end
end
配置存储在/etc/environment
## Database
export DATABASE_NAME=''
export DATABASE_USERNAME=''
export DATABASE_PASSWORD=''
export DATABASE_HOST=''
export DATABASE_PORT=''
## Amazon S3
export AWS_ACCESS_KEY_ID=''
export AWS_SECRET_ACCESS_KEY=''
export AWS_DATABASE_BACKUP_BUCKET_NAME=''
## Email
export EMAIL_ADDRESS=''
export SMTP_USERNAME=''
export SMTP_PASSWORD=''
错误讯息:
2016/08/19 11:04:34][info] Performing Backup for 'Oktob Production Database Backup (oktob_database_backup)'!
[2016/08/19 11:04:34][info] [ backup 4.2.2 : ruby 2.0.0p647 (2015-08-18 revision 51631) [x86_64-linux] ]
[2016/08/19 11:04:34][warn] Cleaner::Error: Cleanup Warning
[2016/08/19 11:04:34][warn] The temporary packaging folder still exists!
[2016/08/19 11:04:34][warn] '/root/Backup/.tmp/oktob_database_backup'
[2016/08/19 11:04:34][warn] It will now be removed.
[2016/08/19 11:04:34][warn]
[2016/08/19 11:04:34][warn] Please check the log for messages and/or your notifications
[2016/08/19 11:04:34][warn] concerning this backup: 'Oktob Production Database Backup (oktob_database_backup)'
[2016/08/19 11:04:34][warn] The temporary files which had to be removed should not have existed.
[2016/08/19 11:04:34][info] Database::PostgreSQL Started...
[2016/08/19 11:04:34][info] Using Compressor::Gzip for compression.
[2016/08/19 11:04:34][info] Command: '/bin/gzip'
[2016/08/19 11:04:34][info] Ext: '.gz'
[2016/08/19 11:04:34][error] Model::Error: Backup for Oktob Production Database Backup (oktob_database_backup) Failed!
[2016/08/19 11:04:34][error] --- Wrapped Exception ---
[2016/08/19 11:04:34][error] Database::PostgreSQL::Error: Dump Failed!
[2016/08/19 11:04:34][error] Pipeline STDERR Messages:
[2016/08/19 11:04:34][error] (Note: may be interleaved if multiple commands returned error messages)
[2016/08/19 11:04:34][error]
[2016/08/19 11:04:34][error] pg_dump: [archiver (db)] connection to database "oktob" failed: could not connect to server: Connection refused
[2016/08/19 11:04:34][error] Is the server running on host "172.17.0.1" and accepting
[2016/08/19 11:04:34][error] TCP/IP connections on port 5432?
[2016/08/19 11:04:34][error] The following system errors were returned:
[2016/08/19 11:04:34][error] Errno::EPERM: Operation not permitted - 'pg_dump' returned exit code: 1
[2016/08/19 11:04:34][error]
[2016/08/19 11:04:34][error] Backtrace:
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/backup-4.2.2/lib/backup/database/postgresql.rb:72:in `perform!'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/backup-4.2.2/lib/backup/model.rb:269:in `each'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/backup-4.2.2/lib/backup/model.rb:269:in `block in perform!'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/backup-4.2.2/lib/backup/model.rb:268:in `each'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/backup-4.2.2/lib/backup/model.rb:268:in `perform!'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/backup-4.2.2/lib/backup/cli.rb:156:in `perform'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/thor-0.18.1/lib/thor/command.rb:27:in `run'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/thor-0.18.1/lib/thor/invocation.rb:120:in `invoke_command'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/thor-0.18.1/lib/thor.rb:363:in `dispatch'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/thor-0.18.1/lib/thor/base.rb:439:in `start'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/gems/backup-4.2.2/bin/backup:5:in `<top (required)>'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/bin/backup:23:in `load'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/bin/backup:23:in `<main>'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/bin/ruby_executable_hooks:15:in `eval'
[2016/08/19 11:04:34][error] /usr/local/rvm/gems/ruby-2.0.0-p647/bin/ruby_executable_hooks:15:in `<main>'
[2016/08/19 11:04:34][warn] Cleaner::Error: Cleanup Warning
[2016/08/19 11:04:34][warn] The temporary packaging folder still exists!
[2016/08/19 11:04:34][warn] '/root/Backup/.tmp/oktob_database_backup'
[2016/08/19 11:04:34][warn] This folder may contain completed Archives and/or Database backups.
[2016/08/19 11:04:34][warn]
[2016/08/19 11:04:34][warn] Make sure you check these files before the next scheduled backup for
[2016/08/19 11:04:34][warn] 'Oktob Production Database Backup (oktob_database_backup)'
[2016/08/19 11:04:34][warn] These files will be removed at that time!
[2016/08/19 11:04:34][info] Sending notification using Notifier::Mail...
该应用正常运行,但不确定移动后备份发生了什么。我试图重新启动数据库容器和man app,但是缺少了一些东西。