mirror of
https://github.com/samuelclay/NewsBlur.git
synced 2025-09-18 21:50:56 +00:00
Executable backups for mongo
This commit is contained in:
parent
cf145e9517
commit
607da1a524
3 changed files with 7 additions and 4 deletions
|
@ -130,15 +130,18 @@
|
|||
hour: "4"
|
||||
job: /srv/newsblur/docker/mongo/backup_mongo.sh
|
||||
when: '"db-mongo-secondary1" in inventory_hostname'
|
||||
tags:
|
||||
- mongo-backup
|
||||
|
||||
- name: Add mongo starred_stories+stories backup
|
||||
cron:
|
||||
name: mongo backup
|
||||
name: mongo starred/shared/all stories backup
|
||||
minute: "0"
|
||||
hour: "5"
|
||||
job: /srv/newsblur/docker/mongo/backup_mongo_stories.sh
|
||||
when: '"db-mongo-secondary1" in inventory_hostname'
|
||||
|
||||
tags:
|
||||
- mongo-backup
|
||||
|
||||
# Renaming a db-mongo3 to db-mongo2:
|
||||
# - Change hostname to db-mongo2 on Digital Ocean (doctl)
|
||||
|
|
0
docker/mongo/backup_mongo.sh
Normal file → Executable file
0
docker/mongo/backup_mongo.sh
Normal file → Executable file
|
@ -84,14 +84,14 @@ def rotate(key_prefix, key_ext, bucket_name, daily_backups=7, weekly_backups=4,
|
|||
|
||||
if len(backups) > daily_backups+1 and backups[daily_backups] - backups[daily_backups+1] < timedelta(days=7):
|
||||
key = bucket.Object("{0}{1}{2}".format(key_prefix,backups[daily_backups].strftime("_%Y-%m-%d-%H-%M"), key_ext))
|
||||
logger.debug("deleting daily {0}".format(key))
|
||||
logger.debug("[not] deleting daily {0}".format(key))
|
||||
# key.delete()
|
||||
del backups[daily_backups]
|
||||
|
||||
month_offset = daily_backups + weekly_backups
|
||||
if len(backups) > month_offset+1 and backups[month_offset] - backups[month_offset+1] < timedelta(days=30):
|
||||
key = bucket.Object("{0}{1}{2}".format(key_prefix,backups[month_offset].strftime("_%Y-%m-%d-%H-%M"), key_ext))
|
||||
logger.debug("deleting weekly {0}".format(key))
|
||||
logger.debug("[not] deleting weekly {0}".format(key))
|
||||
# key.delete()
|
||||
del backups[month_offset]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue