예제 #1
0
import os
import sys

NEWSBLUR_DIR = "/srv/newsblur"
sys.path.insert(0, NEWSBLUR_DIR)
VENDOR_DIR = "/srv/newsblur/vendor"
sys.path.insert(0, VENDOR_DIR)
os.environ["DJANGO_SETTINGS_MODULE"] = "settings"

import time
import s3
from django.conf import settings

db_name = "newsblur"
db_pass = settings.DATABASES["default"]["PASSWORD"]
os.environ["PGPASSWORD"] = db_pass
filename = "backup_postgresql_%s.sql.gz" % time.strftime("%Y-%m-%d-%H-%M")
cmd = "/usr/lib/postgresql/9.2/bin/pg_dump -U newsblur -h 127.0.0.1 -Fc %s > %s" % (db_name, filename)
print "Backing up PostgreSQL: %s" % cmd
os.system(cmd)

print "Uploading %s to S3..." % filename
s3.save_file_in_s3(filename, name="postgres/%s" % filename)
os.remove(filename)
예제 #2
0
import os
import sys

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

filename = 'backup_redis/backup_redis_%s.rdb.gz' % time.strftime(
    '%Y-%m-%d-%H-%M')
path = '/var/lib/redis/dump.rdb'
print 'Uploading %s (from %s) to S3...' % (filename, path)
s3.save_file_in_s3(path, name=filename)
예제 #3
0
import os
import sys

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

filename = 'backup_redis/backup_redis_%s.rdb.gz' % time.strftime('%Y-%m-%d-%H-%M')
path = '/var/lib/redis/dump.rdb'
print 'Uploading %s (from %s) to S3...' % (filename, path)
s3.save_file_in_s3(path, name=filename)
예제 #4
0
COLLECTIONS = "classifier_tag classifier_author classifier_feed classifier_title userstories shared_stories category category_site sent_emails social_profile social_subscription social_services statistics user_search feedback"
if False:
    COLLECTIONS += " starred_stories"

date = time.strftime('%Y-%m-%d-%H-%M')
collections = COLLECTIONS.split(' ')
db_name = 'pytune'
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)

print "Compressing %s..." % filename
cmd = 'tar -zcf %s %s' % (filename, dir_name)
os.system(cmd)

print 'Uploading %s to S3...' % filename
try:
    s3.save_file_in_s3(filename, name="mongo/%s" % (filename))
except Exception, e:
    print " ****> Exceptions: %s" % e
shutil.rmtree(dir_name)
os.remove(filename)
예제 #5
0
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

COLLECTIONS = "classifier_tag classifier_author classifier_feed classifier_title userstories starred_stories shared_stories category category_site sent_emails social_profile social_subscription social_services statistics feedback"

date = time.strftime('%Y-%m-%d-%H-%M')
collections = COLLECTIONS.split(' ')
db_name = 'newsblur'
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)

print "Compressing %s..." % filename
cmd = 'tar -zcf %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)
예제 #6
0
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 shared_stories category category_site sent_emails social_profile social_subscription social_services statistics feedback"

date = time.strftime('%Y-%m-%d-%H-%M')
collections = COLLECTIONS.split(' ')
db_name = 'newsblur'
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)
예제 #7
0
import os
import sys

NEWSBLUR_DIR = '/srv/newsblur'
sys.path.insert(0, NEWSBLUR_DIR)
VENDOR_DIR = '/srv/newsblur/vendor'
sys.path.insert(0, VENDOR_DIR)
os.environ['DJANGO_SETTINGS_MODULE'] = 'newsblur.settings'

import time
import s3
from django.conf import settings

db_name = 'newsblur'
db_pass = settings.DATABASES['default']['PASSWORD']
os.environ['PGPASSWORD'] = db_pass
filename = 'backup_postgresql_%s.sql.gz' % time.strftime('%Y-%m-%d-%H-%M')
cmd = '/usr/lib/postgresql/9.4/bin/pg_dump -U newsblur -h 127.0.0.1 -Fc %s > %s' % (
    db_name, filename)
print 'Backing up PostgreSQL: %s' % cmd
os.system(cmd)

print 'Uploading %s to S3...' % filename
s3.save_file_in_s3(filename, name="postgres/%s" % filename)
os.remove(filename)
예제 #8
0
import time
import s3

COLLECTIONS = "classifier_tag classifier_author classifier_feed classifier_title userstories shared_stories category category_site sent_emails social_profile social_subscription social_services statistics user_search feedback"
if False:
    COLLECTIONS += " starred_stories"

date = time.strftime('%Y-%m-%d-%H-%M')
collections = COLLECTIONS.split(' ')
db_name = 'newsblur'
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)

print "Compressing %s..." % filename
cmd = 'tar -zcf %s %s' % (filename, dir_name)
os.system(cmd)

print 'Uploading %s to S3...' % filename
try:
    s3.save_file_in_s3(filename, name="mongo/%s" % (filename))
except Exception, e:
    print " ****> Exceptions: %s" % e
shutil.rmtree(dir_name)
os.remove(filename)