capistrano-ash 0.0.13 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/ash/base.rb +45 -4
- data/lib/ash/zend_doctrine.rb +7 -9
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.15
|
data/lib/ash/base.rb
CHANGED
@@ -18,11 +18,12 @@ configuration.load do
|
|
18
18
|
# Set default stages
|
19
19
|
set :stages, %w(staging production)
|
20
20
|
set :default_stge, "staging"
|
21
|
-
|
21
|
+
|
22
22
|
# --------------------------------------------
|
23
23
|
# Task chains
|
24
24
|
# --------------------------------------------
|
25
25
|
after "deploy:setup", "deploy:setup_shared"
|
26
|
+
after "deploy:setup_shared", "deploy:setup_backups"
|
26
27
|
after "deploy", "deploy:cleanup"
|
27
28
|
|
28
29
|
# --------------------------------------------
|
@@ -53,6 +54,13 @@ configuration.load do
|
|
53
54
|
# phpMyAdmin version
|
54
55
|
set :pma_version, "3.3.8"
|
55
56
|
|
57
|
+
# Backups Path
|
58
|
+
_cset(:backups_path) { File.join(deploy_to, "backups") }
|
59
|
+
|
60
|
+
# Define which files or directories you want to exclude from being backed up
|
61
|
+
_cset(:backup_exclude) { [] }
|
62
|
+
set :exclude_string, ''
|
63
|
+
|
56
64
|
# show password requests on windows
|
57
65
|
# (http://weblog.jamisbuck.org/2007/10/14/capistrano-2-1)
|
58
66
|
default_run_options[:pty] = true
|
@@ -65,6 +73,11 @@ configuration.load do
|
|
65
73
|
task :setup_shared do
|
66
74
|
puts "STUB: Setup"
|
67
75
|
end
|
76
|
+
|
77
|
+
desc "Setup backup directory for database and web files"
|
78
|
+
task :setup_backup, :except => { :no_release => true } do
|
79
|
+
run "#{try_sudo} mkdir -p #{backups_path} && #{try_sudo} chmod g+w #{backups_path}"
|
80
|
+
end
|
68
81
|
end
|
69
82
|
|
70
83
|
# --------------------------------------------
|
@@ -137,18 +150,46 @@ configuration.load do
|
|
137
150
|
namespace :backup do
|
138
151
|
desc "Perform a backup of web and database files"
|
139
152
|
task :default do
|
140
|
-
web
|
141
153
|
db
|
154
|
+
web
|
142
155
|
end
|
143
156
|
|
144
157
|
desc "Perform a backup of web files"
|
145
158
|
task :web, :roles => :web do
|
146
|
-
puts "
|
159
|
+
puts "Backing up web files (user uploaded content and previous release)"
|
160
|
+
|
161
|
+
if !backup_exclude.nil? && !backup_exclude.empty?
|
162
|
+
logger.debug "processing backup exclusions..."
|
163
|
+
backup_exclude.each do |pattern|
|
164
|
+
exclude_string << "--exclude '#{pattern}' "
|
165
|
+
end
|
166
|
+
logger.debug "Exclude string = #{exclude_string}"
|
167
|
+
end
|
168
|
+
|
169
|
+
# run "tar -cvpzf #{backups_path}/#{release_name}.tar.gz #{exclude_string} #{current_path} #{shared_path}"
|
170
|
+
|
171
|
+
# Copy the previous release to the /tmp directory
|
172
|
+
logger.debug "Copying previous release to the /tmp/#{release_name} directory"
|
173
|
+
run "rsync -avzrtpL #{exclude_string} #{current_path}/ /tmp/#{release_name}/"
|
174
|
+
# create the tarball of the previous release
|
175
|
+
set :archive_name, "release_B4_#{release_name}.tar.gz"
|
176
|
+
logger.debug "Creating a Tarball of the previous release in #{backups_path}/#{archive_name}"
|
177
|
+
run "cd /tmp && tar -cvpf - ./#{release_name}/ | gzip -c --best > #{backups_path}/#{archive_name}"
|
178
|
+
|
179
|
+
# remove the the temporary copy
|
180
|
+
logger.debug "Removing the tempory copy"
|
181
|
+
run "rm -rf /tmp/#{release_name}"
|
147
182
|
end
|
148
183
|
|
149
184
|
desc "Perform a backup of database files"
|
150
185
|
task :db, :roles => :db do
|
151
|
-
puts "
|
186
|
+
puts "Backing up the database now and putting dump file in the previous release directory"
|
187
|
+
# define the filename (include the current_path so the dump file will be within the dirrectory)
|
188
|
+
filename = "#{current_path}/#{dbname}_dump-#{Time.now.to_s.gsub(/ /, "_")}.sql.gz"
|
189
|
+
# dump the database for the proper environment
|
190
|
+
run "mysqldump -u #{dbuser} -p #{dbname} | gzip -c --best > #{filename}" do |ch, stream, out|
|
191
|
+
ch.send_data "#{dbpass}\n" if out =~ /^Enter password:/
|
192
|
+
end
|
152
193
|
end
|
153
194
|
end
|
154
195
|
|
data/lib/ash/zend_doctrine.rb
CHANGED
@@ -6,15 +6,6 @@ configuration = Capistrano::Configuration.respond_to?(:instance) ?
|
|
6
6
|
Capistrano.configuration(:must_exist)
|
7
7
|
|
8
8
|
configuration.load do
|
9
|
-
# --------------------------------------------
|
10
|
-
# Set some defaults
|
11
|
-
# --------------------------------------------
|
12
|
-
# Deploy to file path
|
13
|
-
set(:deploy_to) { "/var/www/#{application}/#{stage}" }
|
14
|
-
|
15
|
-
# Define your backups directory
|
16
|
-
set(:backup_to) { "#{deploy_to}/backups/" }
|
17
|
-
|
18
9
|
# --------------------------------------------
|
19
10
|
# Calling our Methods
|
20
11
|
# --------------------------------------------
|
@@ -64,4 +55,11 @@ configuration.load do
|
|
64
55
|
end
|
65
56
|
end
|
66
57
|
|
58
|
+
namespace :doctrine do
|
59
|
+
desc "Run Doctrine Migrations"
|
60
|
+
task :migrate, :except => { :no_release => true } do
|
61
|
+
puts "Running Doctrine Migrations..."
|
62
|
+
run "cd #{current_release} && ./scripts/doctrine-cli migrate"
|
63
|
+
end
|
64
|
+
end
|
67
65
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 15
|
9
|
+
version: 0.0.15
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- August Ash
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-12-
|
17
|
+
date: 2010-12-28 00:00:00 -06:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|