Jason,
As Neil said, you might have better luck with explicit semicolons.
Truth-be-told, though, you'd do even better to bottle that up as a
proper shell script and throw it in your application's scripts
directory. Then, your task just becomes:
run "#{current_path}/scripts/backup_database"
Much more scalable, and less prone to strangeness due to how
Capistrano handles the "run" command.
- Jamis
On Jan 16, 2007, at 8:35 PM, Jason Schock wrote:
Hi, I've created the following task:
============
desc "Backup the database by saving a dump"
task :backup_database, :roles => :db, :only => {:primary => true} do
run <<-CMD
right_now=$(date +"%m.%d.%Y-%H.%M.%S")
dumpfile=#{application}_#{database_name}-${right_now}.pg_dump
if [ ! -d #{deploy_to}/../database_backups ];
then
mkdir -p #{deploy_to}/../database_backups;
fi
pg_dump --format=c #{database_name} >
#{deploy_to}/../database_backups/$dumpfile
CMD
end
============
And here is the output of the task:
============
# cap -f config/deploy_to_demo backup_database
* executing task backup_database
* executing "right_now=$(date +\"%m.%d.%Y-%H.%M.%S\")\n
dumpfile=filename-${right_now}.pg_dump\n if [ ! -d
/home/demosite/demo/../database_backups ];\n then\n mkdir -p
/home/demosite/demo/../database_backups;\n fi\n pg_dump
--format=c demo_site >
/home/demosite/demo/../database_backups/$dumpfile"
servers: ["my.server.com"]
Password:
[my.sever.com] executing command
** [out :: my.server.com] bash: -c: line 4: syntax error near
unexpected token `then'
** [out :: my.sever.com] bash: -c: line 4: ` mkdir -p
/home/demosite/demo/../database_backups;\'
command finished
command "right_now=$(date +\"%m.%d.%Y-%H.%M.%S\")\\\n
dumpfile=filename-${right_now}.pg_dump\\\n if [ ! -d
/home/demosite/demo/../database_backups ];\\\n then\\\n mkdir
-p /home/demosite/demo/../database_backups;\\\n fi\\\n pg_dump
--format=c demo_site >
/home/demosite/demo/../database_backups/$dumpfile" failed on
my.server.com
============
Anyone have any idea what this is all about? I suspect it's something
to do with whitespace and all those extra slashes, but I don't know if
it's a Capistrano bug or something environmental. I'm running
Capistrano on Mac OS X and deploying to a RH Linux server.
Thanks for any help.
J
>
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---