Last Updated: February 25, 2016
·
613
· toymachiner62

Rails + Capistrano + Myrepono

If you use Myrepono(myrepono.com) and capistrano, you may know that it's a huge pain in the ass to get myrepono setup in a project that uses capistrano because everytime you redeploy your app, it blows away your myrepono files.

I'm come up with a brilliant way of getting around this.

The Idea

The idea is that if you put your myrepono/ in your project root, you can create a symlink from your current/public/ to your myrepono folder.

Myrepono Setup

Add a new domain in myrepono and follow the manual installation instructions. In my case, my myrepono dir is located at /var/www/example.com/myrepono/.

Also create a .htaccess file at this location and put the following contents in it:

AddHandler php-script .php

The Capistrano Task

# Creates a symlink to the myrepono directory which should sit at the project root
task :symlink_myrepono, :roles => :app do
    run "cd #{current_path}/public; ln -s #{deploy_to}/myrepono/ myrepono"
end

The Snippet that goes at the end of your capistrano recipe

after "deploy:install", "deploy:symlink_myrepono"

YAHTZEE!!!

Finally we can have rails projects with myrepono backups!