blavosync 0.3.0 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Blavosync.gemspec +1 -1
- data/VERSION +1 -1
- data/lib/blavosync/recipes/database.rb +5 -33
- data/lib/blavosync/recipes/local.rb +0 -4
- metadata +1 -1
data/Blavosync.gemspec
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.2
|
@@ -6,31 +6,12 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
6
6
|
RAILS_ENV environment variable, which defaults to 'production') and copies it to the local machine
|
7
7
|
DESC
|
8
8
|
task :backup_db, :roles => :db do
|
9
|
-
|
10
|
-
timestamp = most_recent_local_backup(from_env, 'db').to_i
|
11
|
-
last_modified = last_mod_time(db_backup_zip_file).to_i
|
12
|
-
|
13
|
-
if last_modified < (Time.now.to_i - (remote_backup_expires))
|
14
|
-
generate_remote_db_backup
|
15
|
-
should_redownload = true
|
16
|
-
end
|
17
|
-
should_redownload = !(timestamp == last_modified)
|
18
|
-
if should_redownload
|
19
|
-
system "mkdir -p #{tmp_dir}"
|
20
|
-
download(db_backup_zip_file, "#{local_db_backup_file(:env=>from_env, :timestamp=>last_modified)}.#{zip_ext}", :via=> :scp) do|ch, name, sent, total|
|
21
|
-
print "\r\033[1;42m #{File.basename(name)}: #{sent}/#{total} -- #{(sent.to_f * 100 / total.to_f).to_i}% \033[0m"
|
22
|
-
end
|
23
|
-
else
|
24
|
-
print "\r\033[1;42m Your Files are already up-to-date \033[0m\n"
|
25
|
-
@current_timestamp = files.first.to_i
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
desc <<-DESC
|
30
|
-
Regenerate files.
|
31
|
-
DESC
|
32
|
-
task :force_backup_db do
|
9
|
+
last_modified = Time.now.to_i
|
33
10
|
generate_remote_db_backup
|
11
|
+
system "mkdir -p #{tmp_dir}"
|
12
|
+
download(db_backup_zip_file, "#{local_db_backup_file(:env=>from_env, :timestamp=>last_modified)}.#{zip_ext}", :via=> :scp) do|ch, name, sent, total|
|
13
|
+
print "\r\033[1;42m #{File.basename(name)}: #{sent}/#{total} -- #{(sent.to_f * 100 / total.to_f).to_i}% \033[0m"
|
14
|
+
end
|
34
15
|
end
|
35
16
|
|
36
17
|
desc <<-DESC
|
@@ -53,7 +34,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
53
34
|
rm -f #{remote_backup_file}
|
54
35
|
CMD
|
55
36
|
system(cmd.strip)
|
56
|
-
util::tmp::check
|
57
37
|
end
|
58
38
|
|
59
39
|
desc <<-DESC
|
@@ -66,14 +46,6 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
66
46
|
restore_db
|
67
47
|
end
|
68
48
|
end
|
69
|
-
|
70
|
-
desc <<-DESC
|
71
|
-
Ensure that a fresh remote data dump is retrieved before syncing to the local environment.
|
72
|
-
DESC
|
73
|
-
task :resync_db do
|
74
|
-
util::tmp::clean_remote
|
75
|
-
sync_db
|
76
|
-
end
|
77
49
|
end
|
78
50
|
|
79
51
|
end
|
@@ -102,10 +102,6 @@ Capistrano::Configuration.instance(:must_exist).load do |configuration|
|
|
102
102
|
capture("stat -c%Y #{path}") rescue 0
|
103
103
|
end
|
104
104
|
|
105
|
-
def server_cache_valid?(path)
|
106
|
-
capture("[ -f #{path} ] || echo '1'").empty? && ((Time.now.to_i - last_mod_time(path)) <= remote_backup_expires)
|
107
|
-
end
|
108
|
-
|
109
105
|
def generate_remote_db_backup
|
110
106
|
run "mysqldump #{mysql_connection_for(from_env)} > #{db_backup_file}"
|
111
107
|
run "rm -f #{db_backup_zip_file} && #{zip} #{db_backup_file} && rm -f #{db_backup_file}"
|