If you have multiple commands in a run script then you need to separate
them with semicolons, thus:

run %{
 right_now=$(date +"%m.%d.%Y-%H.%M.%S");
 dumpfile=#{application}_#{database_name}-${right_now}.pg_dump;
 [ ! -d #{deploy_to}/../database_backups ] && mkdir -p
#{deploy_to}/../database_backups;
 pg_dump --format=c #{database_name} >
#{deploy_to}/../database_backups/$dumpfile
}

On Jan 17, 3:35 am, "Jason Schock" <[EMAIL PROTECTED]> 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
-~----------~----~----~----~------~----~------~--~---

Reply via email to