aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--servo/management/commands/dbdump.py13
-rw-r--r--servo/management/commands/dumpdb.py20
-rw-r--r--settings.py8
3 files changed, 24 insertions, 17 deletions
diff --git a/servo/management/commands/dbdump.py b/servo/management/commands/dbdump.py
deleted file mode 100644
index 58651a8..0000000
--- a/servo/management/commands/dbdump.py
+++ /dev/null
@@ -1,13 +0,0 @@
-# -*- coding: utf-8 -*-
-
-import subprocess
-from django.conf import settings
-from django.core.management.base import BaseCommand
-
-
-class Command(BaseCommand):
- help = "Dumps DB of this instance to specified file"
-
- def handle(self, *args, **options):
- dbname = settings.DATABASES['default']['NAME']
- #subprocess.call('pg_dump', '-Fc', dbname, '-U', 'pgsql' > "${BACKUPDIR}/${db}_$(date "+%Y%m%d_%H%M").pgdump"
diff --git a/servo/management/commands/dumpdb.py b/servo/management/commands/dumpdb.py
new file mode 100644
index 0000000..c319336
--- /dev/null
+++ b/servo/management/commands/dumpdb.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+
+import os
+import os.path
+import subprocess
+from datetime import datetime
+from django.conf import settings
+from django.core.management.base import BaseCommand
+
+
+class Command(BaseCommand):
+ help = "Dumps DB of this instance to specified file"
+
+ def handle(self, *args, **options):
+ s = settings.DATABASES['default']
+ db, user, pw = s['NAME'], s['USER'], s['PASSWORD']
+ fname = datetime.now().strftime('%Y%m%d_%H%M') + '.pgdump'
+ path = os.path.join(settings.BACKUP_DIR, fname)
+ os.putenv('PGPASSWORD', pw)
+ subprocess.call(['pg_dump', '-Fc', db, '-U', user, '-f', path])
diff --git a/settings.py b/settings.py
index 9bc0b87..3b0b41c 100644
--- a/settings.py
+++ b/settings.py
@@ -14,7 +14,7 @@ MESSAGE_TAGS = {
}
BASE_DIR = os.path.dirname(__file__)
-APP_DIR = os.path.join(BASE_DIR, 'servo')
+APP_DIR = os.path.join(BASE_DIR, 'servo')
ADMINS = (
('ServoApp Support', 'support@servoapp.com'),
@@ -217,13 +217,13 @@ REST_FRAMEWORK = {
ENABLE_RULES = False
TIMEZONE = 'Europe/Helsinki'
-BACKUP_DIR = '/opt/servo/backups'
+BACKUP_DIR = os.path.join(BASE_DIR, 'backups')
GSX_CERT = 'uploads/settings/gsx_cert.pem'
-GSX_KEY = 'uploads/settings/gsx_key.pem'
+GSX_KEY = 'uploads/settings/gsx_key.pem'
os.environ['GSX_CERT'] = GSX_CERT
-os.environ['GSX_KEY'] = GSX_KEY
+os.environ['GSX_KEY'] = GSX_KEY
CELERYBEAT_SCHEDULE = {
'check_mail': {