aboutsummaryrefslogtreecommitdiffstats
path: root/servo/management
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2015-11-19 10:06:52 +0200
committerFilipp Lepalaan <filipp@mac.com>2015-11-19 10:06:52 +0200
commitc1bb9c28adcdc9f9373f236d53b7c8c916b19b10 (patch)
tree8e900ef7cf0e9d66a2d547f86697a704fd04280a /servo/management
parentdd9b4920713145e51eeef74063c15d715a746d37 (diff)
downloadServo-c1bb9c28adcdc9f9373f236d53b7c8c916b19b10.tar.gz
Servo-c1bb9c28adcdc9f9373f236d53b7c8c916b19b10.tar.bz2
Servo-c1bb9c28adcdc9f9373f236d53b7c8c916b19b10.zip
Create backup dir if doesn't exist
Diffstat (limited to 'servo/management')
-rw-r--r--servo/management/commands/dumpdb.py4
1 files changed, 4 insertions, 0 deletions
diff --git a/servo/management/commands/dumpdb.py b/servo/management/commands/dumpdb.py
index c319336..6032dc4 100644
--- a/servo/management/commands/dumpdb.py
+++ b/servo/management/commands/dumpdb.py
@@ -15,6 +15,10 @@ class Command(BaseCommand):
s = settings.DATABASES['default']
db, user, pw = s['NAME'], s['USER'], s['PASSWORD']
fname = datetime.now().strftime('%Y%m%d_%H%M') + '.pgdump'
+
+ if not os.path.exists(settings.BACKUP_DIR):
+ os.mkdir(settings.BACKUP_DIR)
+
path = os.path.join(settings.BACKUP_DIR, fname)
os.putenv('PGPASSWORD', pw)
subprocess.call(['pg_dump', '-Fc', db, '-U', user, '-f', path])