Method: MongoSync.push

Defined in:
lib/mongo_sync.rb

.push(config = nil) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/mongo_sync.rb', line 28

def self.push(config = nil)
    configs = MongoSync::Configuration.parse(config)
    tmpdir  = new_tmp_dir

    puts        "Dumping Local DB to #{tmpdir}..."
    system_run  "mongodump \
                    -d #{configs['local']['db']} \
                    -o #{tmpdir} > /dev/null"

    puts        "Overwriting Remote DB with Dump..."
    system_run  "mongorestore \
                    -h #{configs['remote']['host']['url']}:#{configs['remote']['host']['port']} \
                    -d #{configs['remote']['db']} \
                    -u #{configs['remote']['access']['username']} \
                    -p #{configs['remote']['access']['password']} \
                    #{tmpdir}/#{configs['remote']['db']} \
                    --drop > /dev/null"

    clean_up(tmpdir)
    done_msg
end