diff options
author | Filipp Lepalaan <filipp@mac.com> | 2015-11-19 10:06:52 +0200 |
---|---|---|
committer | Filipp Lepalaan <filipp@mac.com> | 2015-11-19 10:06:52 +0200 |
commit | c1bb9c28adcdc9f9373f236d53b7c8c916b19b10 (patch) | |
tree | 8e900ef7cf0e9d66a2d547f86697a704fd04280a /servo | |
parent | dd9b4920713145e51eeef74063c15d715a746d37 (diff) | |
download | Servo-c1bb9c28adcdc9f9373f236d53b7c8c916b19b10.tar.gz Servo-c1bb9c28adcdc9f9373f236d53b7c8c916b19b10.tar.bz2 Servo-c1bb9c28adcdc9f9373f236d53b7c8c916b19b10.zip |
Create backup dir if doesn't exist
Diffstat (limited to 'servo')
-rw-r--r-- | servo/management/commands/dumpdb.py | 4 |
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]) |