def post(self): """ .. http:get:: /databasebackup Get a tar copy of the database. **Example request**: .. selfourcecode:: http GET /databasebackup HTTP/1.1 **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: application/json :statuscode 200: Database backup successfully returned :statuscode 400: database backup failed to be generated """ zip_file = request.files["primary_file"] # zip_file is a file object subprocess.call("mkdir -p /dump", shell=True) filename = "/dump/mongo_dump_restore.tar.gz" zip_file.save(filename) restore_mongodump(filename) subprocess.call("rm " + filename, shell=True) return redirect("/dashboard/experiment_list")
def post(self): """ .. http:get:: /databaseBackup Get a tar copy of the database. **Example request**: .. selfourcecode:: http GET /databaseBackup HTTP/1.1 **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: application/json :statuscode 200: Database backup successfully returned :statuscode 400: database backup failed to be generated """ name = str( next.utils.datetimeNow().strftime("%Y-%m-%d_%H:%M:%S")) + '.zip' primary_file = request.files['primary_file'] restore_mongodump(primary_file, name) return redirect('/dashboard/experiment_list')
def post(self): """ .. http:get:: /databaseBackup Get a tar copy of the database. **Example request**: .. selfourcecode:: http GET /databaseBackup HTTP/1.1 **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: application/json :statuscode 200: Database backup successfully returned :statuscode 400: database backup failed to be generated """ zip_file = request.files['primary_file'] # zip_file is a file object subprocess.call('mkdir -p /dump',shell=True) filename = '/dump/mongo_dump_restore.tar.gz' zip_file.save(filename) restore_mongodump(filename) subprocess.call('rm '+filename,shell=True) return redirect('/dashboard/{}/experiment_list'.format(constants.SITE_KEY))
def post(self): """ .. http:get:: /databaseBackup Get a tar copy of the database. **Example request**: .. selfourcecode:: http GET /databaseBackup HTTP/1.1 **Example response**: .. sourcecode:: http HTTP/1.1 200 OK Vary: Accept Content-Type: application/json :statuscode 200: Database backup successfully returned :statuscode 400: database backup failed to be generated """ zip_file = request.files['primary_file'] # zip_file is a file object subprocess.call('mkdir -p /dump',shell=True) filename = '/dump/mongo_dump_restore.tar.gz' zip_file.save(filename) restore_mongodump(filename) subprocess.call('rm '+filename,shell=True) if constants.SITE_KEY: dashboard_prefix = '/dashboard/{}'.format(constants.SITE_KEY) else: dashboard_prefix = '/dashboard' return redirect(dashboard_prefix + '/experiment_list')
import sys sys.path.append("/next_backend") import subprocess import next.constants as constants import next.database.database_lib as db_lib import os AWS_BUCKET_NAME = os.environ['AWS_BUCKET_NAME'] try: dump_filename = sys.argv[1] except: "Must provide a filename from the 'next-database-backups' bucket.\n python daemon_database_restore.py mongo_dump_next-test1.discovery.wisc.edu_2015-04-21_04:50:38.tar.gz" from boto.s3.connection import S3Connection from boto.s3.key import Key import boto # boto.set_stream_logger('boto') conn = S3Connection(constants.AWS_ACCESS_ID, constants.AWS_SECRET_ACCESS_KEY) b = conn.get_bucket(AWS_BUCKET_NAME) k = Key(b) k.key = dump_filename #'mongo_dump_next-test1.discovery.wisc.edu_2015-04-21_04:50:38.tar.gz' filename = 'mongo_dump.tar.gz' k.get_contents_to_filename(filename) db_lib.restore_mongodump(filename) subprocess.call('rm ' + filename, shell=True)
import next.database.database_lib as db_lib import os AWS_BUCKET_NAME = os.environ['AWS_BUCKET_NAME'] try: dump_filename = sys.argv[1] except: "Must provide a filename from the 'next-database-backups' bucket.\n python daemon_database_restore.py mongo_dump_next-test1.discovery.wisc.edu_2015-04-21_04:50:38.tar.gz" from boto.s3.connection import S3Connection from boto.s3.key import Key import boto # boto.set_stream_logger('boto') conn = S3Connection(constants.AWS_ACCESS_ID,constants.AWS_SECRET_ACCESS_KEY) b = conn.get_bucket(AWS_BUCKET_NAME) k = Key(b) k.key = dump_filename #'mongo_dump_next-test1.discovery.wisc.edu_2015-04-21_04:50:38.tar.gz' filename = 'mongo_dump.tar.gz' k.get_contents_to_filename(filename) db_lib.restore_mongodump(filename) subprocess.call('rm '+filename,shell=True)