Yeah, it’s simple but useful. Since I’m using sqlite at the moment, it’s just a copy but you could run any command in a similar way. I’m also tagging the backup name with a date. Here’s a snip from my Capistrano deploy file….
# ...snip...
namespace :deploy do
task :restart do
t=Time.now
run "cp /path/to/db.sqlite3 /path/to/backup/#{t.year}-#{t.month}-#{t.day}_#{t.hour}:#{t.min}:#{t.sec}_db.sqlite3"
run "touch #{current_path}/tmp/restart.txt"
end
end
Posted: May 20th, 2010 | Author: jay | Filed under: Code | Tags: backup, capistrano, database, db, deploy, sqlite | No Comments »
Pretty simple, but wanted to log here so I can look this up in the future…
I wanted to deploy to both a stage and a live site. Here’s how that went down:
First I installed the capistrano-ext gem. Second, I edited my Capfile to look like this:
1
2
3
| require 'capistrano/ext/multistage'
set :default_stage, "beta"
set :stages, %w(beta live) |
Third, I created a deploy folder and added my two recipes there. beta.rb looks like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
| load 'deploy' if respond_to?(:namespace) # cap2 differentiator
default_run_options[:pty] = true
# be sure to change these
set :user, 'username'
set :domain, 'beta.example.org'
set :application, 'fundastache'
# the rest should be good
set :repository, "#{user}@#{domain}:git/#{application}.git"
#set :repository, "/home/#{user}/git/#{application}.git"
set :deploy_to, "/home/#{user}/#{domain}"
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false
server domain, :app, :web
namespace :deploy do
task :restart do
run "touch #{current_path}/tmp/restart.txt"
end
end |
The live recipe looks almost identical.
Now when I
the site is deployed to the live environment and when I
or simply
the site is deployed to the beta site.
Posted: April 23rd, 2010 | Author: jay | Filed under: Code | Tags: beta, capistrano, deploy, production, recipe, stage | No Comments »