remove database_backup.py, add note in README.md about what should be backed up

This commit is contained in:
jesopo 2019-12-06 17:07:25 +00:00
parent 2d3316185b
commit 9664e275f4
2 changed files with 3 additions and 29 deletions

View file

@ -7,6 +7,9 @@ Python3 event-driven modular IRC bot!
## Setup
See [docs/help/setup.md](docs/help/setup.md).
## Backups
If you wish to create backups of your BitBot instance (which you should, [borgbackup](https://borgbackup.readthedocs.io/en/stable/) is a good option), I advise backing up the entirety of `~/.bitbot` - where BitBot by-default keeps config files, database files and rotated log files.
## Github, Gitea and GitLab web hooks
I run BitBot as-a-service on most popular networks (willing to add more networks!) and offer github/gitea/gitlab webhook to IRC notifications for free to FOSS projects. Contact me for more information!

View file

@ -1,29 +0,0 @@
import datetime, glob, os, shutil, time
from src import ModuleManager, utils
BACKUP_INTERVAL = 60*60 # 1 hour
BACKUP_COUNT = 5
class Module(ModuleManager.BaseModule):
def on_load(self):
now = datetime.datetime.now()
until_next_hour = 60-now.second
until_next_hour += ((60-(now.minute+1))*60)
self.timers.add("database-backup", self._backup, BACKUP_INTERVAL,
time.time()+until_next_hour)
def _backup(self, timer):
location = self.bot.database.location
files = glob.glob("%s.*.back" % location)
files = sorted(files)
while len(files) > 4:
os.remove(files[-1])
files.pop(-1)
suffix = datetime.datetime.now().strftime("%y-%m-%d.%H:%M:%S")
backup_file = "%s.%s.back" % (location, suffix)
shutil.copy2(location, backup_file)
timer.redo()