mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
DataDB default name to 10, dbsmerge small corrections
This commit is contained in:
@@ -1,24 +1,22 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# depends:
|
||||
# ^ pymongo
|
||||
# asserts:
|
||||
# ^ destination mongo database exists and the destination user can auth on it
|
||||
# ^ pymongo # install via: easy_install pymongo
|
||||
# behaviour:
|
||||
# ^ the script will "move" the collections if source and target server are the same
|
||||
# but will "copy" (dump/restore) if source and target servers are different
|
||||
|
||||
from_host = '127.0.0.1'
|
||||
from_port = '27017'
|
||||
from_db = 'cgrates2'
|
||||
from_db = '11'
|
||||
from_user = 'cgrates'
|
||||
from_pass = 'CGRateS.org'
|
||||
from_pass = ''
|
||||
|
||||
to_host = '127.0.0.1'
|
||||
to_port = '27017'
|
||||
to_db = 'cgrates2'
|
||||
to_db = '10'
|
||||
to_user = 'cgrates'
|
||||
to_pass = 'CGRateS.org'
|
||||
to_pass = ''
|
||||
|
||||
dump_folder = 'dump'
|
||||
|
||||
@@ -27,6 +25,8 @@ from urllib import quote_plus
|
||||
from collections import OrderedDict
|
||||
|
||||
mongo_from_url = 'mongodb://' + from_user + ':' + quote_plus(from_pass) + '@'+ from_host + ':' + from_port + '/' + from_db
|
||||
if from_pass == '': # disabled auth
|
||||
mongo_from_url = 'mongodb://' + from_host + ':' + from_port + '/' + from_db
|
||||
client = MongoClient(mongo_from_url)
|
||||
|
||||
db = client[from_db]
|
||||
@@ -39,10 +39,13 @@ if len(cols) > 0:
|
||||
print('Migrating on same server...')
|
||||
print('Found %d collections on source. Moving...' % len(cols))
|
||||
i = 0
|
||||
for col in db.collection_names():
|
||||
for col in cols:
|
||||
i += 1
|
||||
print('Moving colection %s (%d of %d)...' % (col, i, len(cols)))
|
||||
client.admin.command(OrderedDict([('renameCollection', from_db + '.' + col), ('to', to_db + '.' + col)]))
|
||||
try:
|
||||
client.admin.command(OrderedDict([('renameCollection', from_db + '.' + col), ('to', to_db + '.' + col)]))
|
||||
except:
|
||||
continue
|
||||
# different servers
|
||||
else:
|
||||
import subprocess
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
# depends:
|
||||
# ^ redis
|
||||
# ^ redis # install via easy_install redis
|
||||
# asserts:
|
||||
# ^ destination redis is not password protected when connected from source redis server
|
||||
# (https://github.com/antirez/redis/pull/2507)
|
||||
@@ -10,12 +10,12 @@
|
||||
|
||||
from_host = '127.0.0.1'
|
||||
from_port = 6379
|
||||
from_db = 0
|
||||
from_db = 11
|
||||
from_pass = ''
|
||||
|
||||
to_host = '127.0.0.1'
|
||||
to_port = 6380
|
||||
to_db = 0
|
||||
to_port = 6379
|
||||
to_db = 10
|
||||
to_pass = '' # Not used
|
||||
|
||||
keymask = '*'
|
||||
|
||||
Reference in New Issue
Block a user