capifony 2.0.2 → 2.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/symfony1.rb +43 -17
- metadata +4 -4
data/CHANGELOG
CHANGED
data/lib/symfony1.rb
CHANGED
@@ -419,7 +419,7 @@ namespace :database do
|
|
419
419
|
namespace :dump do
|
420
420
|
desc "Dump remote database"
|
421
421
|
task :remote do
|
422
|
-
filename = "#{application}.remote_dump.#{Time.now.to_i}.sql.
|
422
|
+
filename = "#{application}.remote_dump.#{Time.now.to_i}.sql.gz"
|
423
423
|
file = "/tmp/#{filename}"
|
424
424
|
sqlfile = "#{application}_dump.sql"
|
425
425
|
config = ""
|
@@ -430,62 +430,88 @@ namespace :database do
|
|
430
430
|
|
431
431
|
case config['type']
|
432
432
|
when 'mysql'
|
433
|
-
run "mysqldump -u#{config['user']} --password='#{config['pass']}' #{config['db']} |
|
433
|
+
run "mysqldump -u#{config['user']} --password='#{config['pass']}' #{config['db']} | gzip -c > #{file}" do |ch, stream, data|
|
434
434
|
puts data
|
435
435
|
end
|
436
436
|
when 'pgsql'
|
437
|
-
run "pg_dump -U #{config['user']} --password='#{config['pass']}' #{config['db']} |
|
437
|
+
run "pg_dump -U #{config['user']} --password='#{config['pass']}' #{config['db']} | gzip -c > #{file}" do |ch, stream, data|
|
438
438
|
puts data
|
439
439
|
end
|
440
440
|
end
|
441
441
|
|
442
|
-
|
442
|
+
require "FileUtils"
|
443
|
+
FileUtils.mkdir_p("backups")
|
443
444
|
get file, "backups/#{filename}"
|
444
|
-
|
445
|
+
begin
|
446
|
+
FileUtils.ln_sf(filename, "backups/#{application}.remote_dump.latest.sql.gz")
|
447
|
+
rescue NotImplementedError # hack for windows which doesnt support symlinks
|
448
|
+
FileUtils.cp_r("backups/#{filename}", "backups/#{application}.remote_dump.latest.sql.gz")
|
449
|
+
end
|
445
450
|
run "rm #{file}"
|
446
451
|
end
|
447
452
|
|
448
453
|
desc "Dump local database"
|
449
454
|
task :local do
|
450
|
-
filename = "#{application}.local_dump.#{Time.now.to_i}.sql.
|
455
|
+
filename = "#{application}.local_dump.#{Time.now.to_i}.sql.gz"
|
456
|
+
tmpfile = "backups/#{application}_dump_tmp.sql"
|
451
457
|
file = "backups/#{filename}"
|
452
458
|
config = load_database_config IO.read('config/databases.yml'), symfony_env_local
|
453
459
|
sqlfile = "#{application}_dump.sql"
|
454
460
|
|
455
|
-
|
461
|
+
require "FileUtils"
|
462
|
+
FileUtils::mkdir_p("backups")
|
456
463
|
case config['type']
|
457
464
|
when 'mysql'
|
458
|
-
`mysqldump -u#{config['user']} --password
|
465
|
+
`mysqldump -u#{config['user']} --password=\"#{config['pass']}\" #{config['db']} > #{tmpfile}`
|
459
466
|
when 'pgsql'
|
460
|
-
`pg_dump -U #{config['user']} --password
|
467
|
+
`pg_dump -U #{config['user']} --password=\"#{config['pass']}\" #{config['db']} > #{tmpfile}`
|
468
|
+
end
|
469
|
+
File.open(tmpfile, "r+") do |f|
|
470
|
+
gz = Zlib::GzipWriter.open(file)
|
471
|
+
while (line = f.gets)
|
472
|
+
gz << line
|
473
|
+
end
|
474
|
+
gz.flush
|
475
|
+
gz.close
|
461
476
|
end
|
462
477
|
|
463
|
-
|
478
|
+
begin
|
479
|
+
FileUtils.ln_sf(filename, "backups/#{application}.local_dump.latest.sql.gz")
|
480
|
+
rescue NotImplementedError # hack for windows which doesnt support symlinks
|
481
|
+
FileUtils.cp_r("backups/#{filename}", "backups/#{application}.local_dump.latest.sql.gz")
|
482
|
+
end
|
483
|
+
FileUtils.rm(tmpfile)
|
464
484
|
end
|
465
485
|
end
|
466
486
|
|
467
487
|
namespace :move do
|
468
488
|
desc "Dump remote database, download it to local & populate here"
|
469
489
|
task :to_local do
|
470
|
-
filename = "#{application}.remote_dump.latest.sql.
|
490
|
+
filename = "#{application}.remote_dump.latest.sql.gz"
|
471
491
|
config = load_database_config IO.read('config/databases.yml'), symfony_env_local
|
472
492
|
sqlfile = "#{application}_dump.sql"
|
473
493
|
|
474
494
|
database.dump.remote
|
475
495
|
|
476
|
-
|
496
|
+
require "FileUtils"
|
497
|
+
f = File.new("backups/#{sqlfile}", "a+")
|
498
|
+
require "zlib"
|
499
|
+
gz = Zlib::GzipReader.new(File.open("backups/#{filename}", "r"))
|
500
|
+
f << gz.read
|
501
|
+
f.close
|
502
|
+
|
477
503
|
case config['type']
|
478
504
|
when 'mysql'
|
479
|
-
`mysql -u#{config['user']} --password
|
505
|
+
`mysql -u#{config['user']} --password=\"#{config['pass']}\" #{config['db']} < backups/#{sqlfile}`
|
480
506
|
when 'pgsql'
|
481
|
-
`psql -U #{config['user']} --password
|
507
|
+
`psql -U #{config['user']} --password=\"#{config['pass']}\" #{config['db']} < backups/#{sqlfile}`
|
482
508
|
end
|
483
|
-
|
509
|
+
FileUtils.rm("backups/#{sqlfile}")
|
484
510
|
end
|
485
511
|
|
486
512
|
desc "Dump local database, load it to remote & populate there"
|
487
513
|
task :to_remote do
|
488
|
-
filename = "#{application}.local_dump.latest.sql.
|
514
|
+
filename = "#{application}.local_dump.latest.sql.gz"
|
489
515
|
file = "backups/#{filename}"
|
490
516
|
sqlfile = "#{application}_dump.sql"
|
491
517
|
config = ""
|
@@ -493,7 +519,7 @@ namespace :database do
|
|
493
519
|
database.dump.local
|
494
520
|
|
495
521
|
upload(file, "/tmp/#{filename}", :via => :scp)
|
496
|
-
run "
|
522
|
+
run "gunzip -c /tmp/#{filename} > /tmp/#{sqlfile}"
|
497
523
|
|
498
524
|
run "cat #{shared_path}/config/databases.yml" do |ch, st, data|
|
499
525
|
config = load_database_config data, symfony_env_prod
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capifony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 9
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 2
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 2.0.
|
9
|
+
- 3
|
10
|
+
version: 2.0.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Konstantin Kudryashov
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-04-
|
18
|
+
date: 2011-04-16 00:00:00 +03:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|