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
我收到此错误:
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"
如果我把它的内容放在远程服务器上运行 - 它工作正常。真的不确定为什么ruby会抛出这个错误。
答案 0 :(得分:1)
请尝试使用backticks:
`mysqldump -u #{fetch(:db_username)} -p#{fetch(:db_password)} #{fetch(:db_database)} > #{shared_path}/db_backups/#{fetch(:backup_filename)}.sql`