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
|
# File 'lib/pgcp.rb', line 17
def cp
config = load_config_file(options['config'] || File.join(ENV['HOME'], '.pgcp.yml'))
if options['log']
Pgcp.log_file = options['log']
end
src = config['databases'][options['source']].symbolize_keys!
dest = config['databases'][options['dest']].symbolize_keys!
begin
tr = Transport.new(src, dest)
if options['table'].include? '*'
if (not options['table'].include? '.') or (options['table'].count('.') > 1)
Pgcp.logger.error 'Globbed tables must have schema name, e.g. public.test* is valid but test* is not.'
return
end
tr.copy_tables(options['table'], force_schema: options['force_schema'])
else
tr.copy_table(options['table'], nil, force_schema: options['force_schema'])
end
rescue Exception => e
Pgcp.logger.error(e.message)
return
end
end
|