在rails中使用gem“backup”备份数据库

时间:2016-02-28 19:50:32

标签: ruby-on-rails database backup

我在rails中使用备份gem来备份数据库时出现问题。

这是我的daily_db_backup.rb

Model.new(:daily_db_backup, 'Description for daily_db_backup') do
  database SQLite do |db|
     db.path               = "home/ec2-user/project/db/production.sqlite3"
     db.sqlitedump_utility = "/usr/bin/sqlite3"
  end

  compress_with Gzip

  store_with S3 do |s3|
     s3.access_key_id     = "my_key_id"
     s3.secret_access_key = "my_access_key"
     s3.region             = 'ap-northeast-2'
     s3.bucket             = 'project'
     s3.path               = 'home/ec2-user/project/db/production.sqlite3'
  end

  notify_by Mail do |mail|
     mail.on_success           = true
     mail.on_warning           = true
     mail.on_failure           = true
     mail.delivery_method      = :sendmail
     mail.from                 = "backup_check@email.com"
     mail.to                   = "myemail@email.com"
  end
end

这些是错误消息

[error] Model::Error: Backup for Description for daily_db_backup (daily_db_backup) Failed!
[error] --- Wrapped Exception ---
[error] Database::SQLite::Error: Database::SQLite Dump Failed!
[error]   Pipeline STDERR Messages:
[error]   (Note: may be interleaved if multiple commands returned error messages)
[error]   
[error]   Error: unable to open database "home/ec2-user/project/db/production.sqlite3": unable to open database file
[error]   The following system errors were returned:
[error]   Errno::EPERM: Operation not permitted - 'echo' returned exit code: 1
那么,我该如何解决这个问题呢?

1 个答案:

答案 0 :(得分:0)

错误日志表示无法打开数据库

“home / ec2-user / project / db / production.sqlite3”:无法打开数据库文件

请检查 production.sqlite3路径

我认为它应该是“/ home / ec2-user ...”