Annotate pg_backup_and_purge.py.

This commit is contained in:
Eklavya Sharma 2016-05-17 11:04:41 +05:30
parent 66bb6394e5
commit 3441f0848c
2 changed files with 5 additions and 4 deletions

View File

@ -7,11 +7,13 @@ import logging
import dateutil.parser
import pytz
from datetime import datetime, timedelta
from typing import List
logging.basicConfig(format="%(asctime)s %(levelname)s: %(message)s")
logger = logging.getLogger(__name__)
def run(args, dry_run=False):
# type: (List[str], bool) -> str
if dry_run:
print("Would have run: " + " ".join(args))
return ""
@ -36,12 +38,12 @@ with open('/var/lib/nagios_state/last_postgres_backup', 'w') as f:
f.write(now.isoformat())
f.write("\n")
backups = {}
backups = {} # type: Dict[datetime, str]
lines = run(['env-wal-e', 'backup-list']).split("\n")
for line in lines[1:]:
if line:
backup_name, date, _, _ = line.split()
backups[dateutil.parser.parse(date)] = backup_name
backup_name, date_str, _, _ = line.split()
backups[dateutil.parser.parse(date_str)] = backup_name
one_month_ago = now - timedelta(days=30)
for date in sorted(backups.keys(), reverse=True):

View File

@ -15,7 +15,6 @@ api/integrations/
bots/jabber_mirror_backend.py
bots/zephyr_mirror_backend.py
docs/conf.py
puppet/zulip_internal/files/postgresql/pg_backup_and_purge.py
tools/deprecated/
zproject/
zerver/lib/bugdown/fenced_code.py