From 95fde8e58f97132397ba985c425942ddc218a15e Mon Sep 17 00:00:00 2001 From: Johannes Erwerle Date: Wed, 13 May 2026 00:05:04 +0200 Subject: [PATCH] added systemd service and timer for quota update --- README.md | 8 ++++++++ .../contrib/communitybackup-quota-update.service | 9 +++++++++ .../contrib/communitybackup-quota-update.timer | 9 +++++++++ .../webui/management/commands/update_used_quota.py | 4 ---- 4 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 community_backup/contrib/communitybackup-quota-update.service create mode 100644 community_backup/contrib/communitybackup-quota-update.timer diff --git a/README.md b/README.md index d3ab045..3722f82 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,14 @@ Create a superuser account ``` +### Repository Quota Updates + +The repository quotas in the UI are updated after each backup. +To update the quota during an operation the `update_used_quota` management command can be executed on a regular basis. + +There are example configs for systemd-timers in `contrib/communitybackup-quota-update.service` and `contrib/communitybackup-quota-update.timer`. Adjust the paths and the timers to your needs. + + ## Custom pages Some pages are specific to your installation. E.g. an imprint. diff --git a/community_backup/contrib/communitybackup-quota-update.service b/community_backup/contrib/communitybackup-quota-update.service new file mode 100644 index 0000000..6c5bf1e --- /dev/null +++ b/community_backup/contrib/communitybackup-quota-update.service @@ -0,0 +1,9 @@ +[Unit] +Description=Update the used quota + +[Service] +User=borg +Group=borg +WorkingDirectory=/opt/community_backup/community-backup/community_backup/ +ExecStart=/opt/community_backup/venv/bin/python manage.py update_used_quota +PrivateTmp=true diff --git a/community_backup/contrib/communitybackup-quota-update.timer b/community_backup/contrib/communitybackup-quota-update.timer new file mode 100644 index 0000000..a29eced --- /dev/null +++ b/community_backup/contrib/communitybackup-quota-update.timer @@ -0,0 +1,9 @@ +[Unit] +Description=Update the used quota on a regular basis + +[Timer] +OnCalendar=*-*-* *:0/5:00 +RandomizedDelaySec=120 + +[Install] +WantedBy=timers.target diff --git a/community_backup/webui/management/commands/update_used_quota.py b/community_backup/webui/management/commands/update_used_quota.py index b19e661..a5ec1cd 100644 --- a/community_backup/webui/management/commands/update_used_quota.py +++ b/community_backup/webui/management/commands/update_used_quota.py @@ -10,8 +10,6 @@ class Command(BaseCommand): parser.add_argument("--repository-id", type=int, nargs="+") def handle(self, *args, **options): - print(options) - qs = BorgRepository.objects.all() if options.get("user_id"): @@ -20,8 +18,6 @@ class Command(BaseCommand): if options.get("repository_id"): qs = qs.filter(pk__in=options.get("repository_id")) - print(qs) - for repo in qs: repo.refresh_quota()