diff --git a/apps/rss_feeds/models.py b/apps/rss_feeds/models.py index 818b3ac87..5fa3465f3 100644 --- a/apps/rss_feeds/models.py +++ b/apps/rss_feeds/models.py @@ -265,7 +265,7 @@ class Feed(models.Model): # history.delete() if status_code not in (200, 304): fetch_history = map(lambda h: h.status_code, - MFeedFetchHistory.objects(feed_id=self.pk)[:10]) + MFeedFetchHistory.objects(feed_id=self.pk)[:50]) self.count_errors_in_history(fetch_history, status_code, 'feed') elif self.has_feed_exception: self.has_feed_exception = False @@ -284,7 +284,7 @@ class Feed(models.Model): if status_code not in (200, 304): fetch_history = map(lambda h: h.status_code, - MPageFetchHistory.objects(feed_id=self.pk)[:10]) + MPageFetchHistory.objects(feed_id=self.pk)[:50]) self.count_errors_in_history(fetch_history, status_code, 'page') elif self.has_page_exception: self.has_page_exception = False @@ -292,8 +292,8 @@ class Feed(models.Model): self.save() def count_errors_in_history(self, fetch_history, status_code, exception_type): - non_errors = [h for h in fetch_history if int(h) in (200, 304)] - errors = [h for h in fetch_history if int(h) not in (200, 304)] + non_errors = [h for h in fetch_history if int(h) in (200, 304)] + errors = [h for h in fetch_history if int(h) not in (200, 304)] if len(non_errors) == 0 and len(errors) >= 1: if exception_type == 'feed': diff --git a/utils/backups/backup_psql.py b/utils/backups/backup_psql.py new file mode 100644 index 000000000..06bdceb75 --- /dev/null +++ b/utils/backups/backup_psql.py @@ -0,0 +1,21 @@ +import os +import sys +import time +import s3 +from django.conf import settings + +db_name = 'newsblur' +db_pass = settings.DATABASES['default']['PASSWORD'] +CURRENT_DIR = os.path.dirname(__file__) +NEWSBLUR_DIR = ''.join([CURRENT_DIR, '../../']) + +os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' +os.environ['PGPASSWORD'] = db_pass +sys.path.insert(0, NEWSBLUR_DIR) + +filename = 'backup_postgresql_%s.sql.gz' % time.strftime('%Y-%m-%d-%H-%M') +cmd = 'pg_dump -U newsblur -Fc %s > %s' % (db_name, filename) +os.system(cmd) + +s3.save_file_in_s3(filename) +os.remove(filename) \ No newline at end of file