<commit_before>import os
import sys
import shutil

CURRENT_DIR  = os.path.dirname(__file__)
NEWSBLUR_DIR = ''.join([CURRENT_DIR, '/../../'])
sys.path.insert(0, NEWSBLUR_DIR)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import time
import s3
from django.conf import settings

COLLECTIONS = "classifier_tag classifier_author classifier_feed classifier_title userstories starred_stories"

date = time.strftime('%Y-%m-%d-%H-%M')
collections = COLLECTIONS.split(' ')
db_name = settings.MONGO_DB.get('NAME')
db_pass = settings.MONGO_DB.get('PASSWORD')
dir_name = 'backup_mongo_%s' % date
filename = '%s.tgz' % dir_name

os.mkdir(dir_name)

for collection in collections:
    cmd = 'mongodump  --db %s --collection %s -o %s' % (db_name, collection, dir_name)
    print "Dumping %s: %s" % (collection, cmd)
    os.system(cmd)
    
cmd = 'tar -jcf %s %s' % (filename, dir_name)
os.system(cmd)

print 'Uploading %s to S3...' % filename
s3.save_file_in_s3(filename)
shutil.rmtree(dir_name)
os.remove(filename)<commit_msg>Fixing mongo backups to use new mongo_db settings.<commit_after>import os
import sys
import shutil

CURRENT_DIR  = os.path.dirname(__file__)
NEWSBLUR_DIR = ''.join([CURRENT_DIR, '/../../'])
sys.path.insert(0, NEWSBLUR_DIR)
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'

import time
import s3
from django.conf import settings

COLLECTIONS = "classifier_tag classifier_author classifier_feed classifier_title userstories starred_stories"

date = time.strftime('%Y-%m-%d-%H-%M')
collections = COLLECTIONS.split(' ')
db_name = settings.MONGO_DB.get('name')
dir_name = 'backup_mongo_%s' % date
filename = '%s.tgz' % dir_name

os.mkdir(dir_name)

for collection in collections:
    cmd = 'mongodump  --db %s --collection %s -o %s' % (db_name, collection, dir_name)
    print "Dumping %s: %s" % (collection, cmd)
    os.system(cmd)

cmd = 'tar -jcf %s %s' % (filename, dir_name)
os.system(cmd)

print 'Uploading %s to S3...' % filename
s3.save_file_in_s3(filename)
shutil.rmtree(dir_name)
os.remove(filename)
{'fraction_non_alphanumeric': 0.1454725383473528, 'fraction_numerical': 0.004948045522018802, 'mean_word_length': 5.017857142857143, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4797939', 'n_tokens_mistral': 769, 'n_tokens_neox': 744, 'n_words': 170}