2016-02-21 71 views
0
desc "Takes a database dump from remote server" 
    task :backup do 
    invoke 'db:backup_name' 
     on roles(:db) do 

    run "mysqldump -u #{fetch(:db_username)} -p#{fetch(:db_password)} #{fetch(:db_database)} > #{shared_path}/db_backups/#{fetch(:backup_filename)}.sql" 

    system('mkdir -p db_backups') 
    download! "#{fetch(:backup_file)}", "db_backups/#{fetch(:backup_filename)}.sql" 

    within release_path do 
     execute :rm, "#{fetch(:backup_file)}" 
    end 

    end 
end 

我得到這個錯誤:在這條線錯誤的參數數目(1 0)運行Capistrano的時候(紅寶石)

wrong number of arguments (1 for 0) 

run "mysqldump -u #{fetch(:db_username)} -p#{fetch(:db_password)} #{fetch(:db_database)} > #{shared_path}/db_backups/#{fetch(:backup_filename)}.sql" 

如果我把內容這並在遠程服務器上運行它 - 它工作正常。真的不知道爲什麼紅寶石拋出這個錯誤。

回答

1

嘗試使用backticks代替:

`mysqldump -u #{fetch(:db_username)} -p#{fetch(:db_password)} #{fetch(:db_database)} > #{shared_path}/db_backups/#{fetch(:backup_filename)}.sql`