From 9664e275f4fc0134fb35aa8252cef32eb0b1e494 Mon Sep 17 00:00:00 2001 From: jesopo Date: Fri, 6 Dec 2019 17:07:25 +0000 Subject: [PATCH] remove database_backup.py, add note in README.md about what should be backed up --- README.md | 3 +++ modules/database_backup.py | 29 ----------------------------- 2 files changed, 3 insertions(+), 29 deletions(-) delete mode 100644 modules/database_backup.py diff --git a/README.md b/README.md index 72db833b..05ecbb73 100644 --- a/README.md +++ b/README.md @@ -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! diff --git a/modules/database_backup.py b/modules/database_backup.py deleted file mode 100644 index cd9a01c9..00000000 --- a/modules/database_backup.py +++ /dev/null @@ -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()