Switch to side-by-side view

--- a/scripts/backup_project.py
+++ b/scripts/backup_project.py
@@ -12,27 +12,32 @@
 
 log = logging.getLogger(__name__)
 
-MONGO_HOME=os.environ.get('MONGO_HOME', '')
+MONGO_HOME=os.environ.get('MONGO_HOME', '/usr')
 MONGO_DUMP=os.path.join(MONGO_HOME, 'bin/mongodump')
 MONGO_RESTORE=os.path.join(MONGO_HOME, 'bin/mongorestore')
 
 def main():
-    if len(sys.argv) != 2:
-        log.error('Usage: %s <shortname>', sys.argv[0])
+    if len(sys.argv) not in (2,3):
+        log.error('Usage: %s <shortname> [<backup_dir>]', sys.argv[0])
         return
     pname = sys.argv[1]
-    log.info('Backing up %s', pname)
     project = M.Project.query.get(shortname=pname)
     if project is None:
         log.fatal('Project %s not found', pname)
+        print 'Project %s not found' % pname
         return
-    dump_project(project)
+    if len(sys.argv) == 3:
+        backup_dir = sys.argv[2]
+    else:
+        pname = project.shortname
+        gid = project.tool_data.get('sfx', {}).get('group_id', project._id)
+        dirname = '%s-%s.purge' % (pname, gid)
+        backup_dir = os.path.join(
+            os.getcwd(), dirname)
+    log.info('Backing up %s to %s', pname, backup_dir)
+    dump_project(project, backup_dir)
 
-def dump_project(project):
-    pname = project.shortname
-    gid = project.tool_data.get('sfx', {}).get('group_id', project._id)
-    dirname = '%s-%s.purge' % (pname, gid)
-    log.info('Backup %s to %s', pname, dirname)
+def dump_project(project, dirname):
     os.system('%s --db %s -o %s' % (
             MONGO_DUMP, project.database, dirname))
     with open(os.path.join(dirname, 'project.json'), 'w') as fp: