Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to run a custom rake task from mina deployment script

i am using mina for deploying my application. I specify the env(staging/production) where i want to deploy the app.

mina deploy on=staging --verbose

i have saved the app env in deploy.rb as

app_env = ENV['on'] || 'staging'

i have a rake task that takes production database backup. As of now, i run that rake task explicitly on my console as

bundle exec rake deploy:backup_prod_db --trace

I want to run that task on every production deployment. How do i do it?

like image 681
prasad.surase Avatar asked Dec 29 '25 23:12

prasad.surase


1 Answers

The mina have special syntax for this. From mina console help page:

Server tasks:
  ...
  mina rails[arguments]   # Execute a Rails command in the current deploy
  mina rake[arguments]    # Execute a Rake command in the current deploy
  mina run[command]       # Runs a command in the server
  ...

So from command line:

$ mina 'rake[deploy:backup_db]'

Or define task in mina deploy config file (config/deploy.rb):

task :backup_db do
  invoke :'rake[deploy:backup_db]'
end
like image 53
oklas Avatar answered Jan 02 '26 10:01

oklas



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!