mirror of
https://codeberg.org/redict/redict.git
synced 2025-01-22 08:08:53 -05:00
50ee0f5be8
Based on feedback from interested parties
35 lines
1.2 KiB
Ruby
35 lines
1.2 KiB
Ruby
# Copyright (C) 2009-2010 Salvatore Sanfilippo
|
|
# SPDX-FileCopyrightText: 2024 Redict Contributors
|
|
# SPDX-FileCopyrightText: 2024 Salvatore Sanfilippo <antirez at gmail dot com>
|
|
#
|
|
# SPDX-License-Identifier: BSD-3-Clause
|
|
# SPDX-License-Identifier: LGPL-3.0-only
|
|
|
|
require 'shellwords'
|
|
|
|
def redisCopy(opts={})
|
|
src = "#{opts[:srchost]}:#{opts[:srcport]}"
|
|
dst = "#{opts[:dsthost]}:#{opts[:dstport]}"
|
|
`redis-copy #{src.shellescape} #{dst.shellescape}`
|
|
rescue Errno::ENOENT
|
|
$stderr.puts 'This utility requires the redis-copy executable',
|
|
'from the redis-copy gem on https://rubygems.org',
|
|
'To install it, run `gem install redis-copy`.'
|
|
exit 1
|
|
end
|
|
|
|
$stderr.puts "This utility is deprecated. Use the redis-copy gem instead."
|
|
if ARGV.length != 4
|
|
puts "Usage: redis-copy.rb <srchost> <srcport> <dsthost> <dstport>"
|
|
exit 1
|
|
end
|
|
puts "WARNING: it's up to you to FLUSHDB the destination host before to continue, press any key when ready."
|
|
STDIN.gets
|
|
srchost = ARGV[0]
|
|
srcport = ARGV[1]
|
|
dsthost = ARGV[2]
|
|
dstport = ARGV[3]
|
|
puts "Copying #{srchost}:#{srcport} into #{dsthost}:#{dstport}"
|
|
redisCopy(:srchost => srchost, :srcport => srcport.to_i,
|
|
:dsthost => dsthost, :dstport => dstport.to_i)
|