12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/dbcp/cli.rb', line 12
def start(argv)
if argv.length < 1
usage
exit 1
end
begin
source = Environment.find(argv.shift)
destination = Environment.find(argv.shift || DEFAULT_DESTINATION)
if source == destination
@logger.fatal "source and destination environments are the same"
exit 3
end
if source.database.adapter != destination.database.adapter
@logger.fatal "source (#{source.database.adapter}) and destination (#{destination.database.adapter}) environments must be the same database type"
exit 4
end
rescue EnvironmentNotFound => e
@logger.fatal e.to_s
exit 2
end
@logger.info "exporting #{source.environment_name}..."
source_snapshot_file = source.export
@logger.info "transferring data..."
destination_snapshot_file = source_snapshot_file.transfer_to(destination)
@logger.info "importing #{destination_snapshot_file.path} to #{destination.environment_name}..."
destination.import destination_snapshot_file
source_snapshot_file.delete
destination_snapshot_file.delete if source_snapshot_file != destination_snapshot_file
end
|