2016-02-28 53 views
0

我在使用rails中的备份gem备份数据库时遇到了问题。在rails中使用gem“backup”备份数据库

这是我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     = "[email protected]" 
    mail.to     = "[email protected]" 
    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 

那么,如何解决这个问题呢?

回答

0

错误日志说无法打开数据库

“家用/ EC2用户/项目/ DB/production.sqlite3”:无法打开数据库文件

请检查您的production.sqlite3路径。我想应该是“/ home/ec2-user ...”