linuxserver / docker-grav

GNU General Public License v3.0
31 stars 11 forks source link

Backup does not purge old backups defined by number via cli/scheduler #19

Closed MrJack91 closed 2 years ago

MrJack91 commented 2 years ago

Expected Behavior

Backup purge rules should be taken into account if executed as scheduler or via cli. Currently it will just purge if we run a backup by the admin plugin.

Current Behavior

Old backups will not be purged if executed by the cli/scheduler. This will lead to space problems.

Steps to Reproduce

  1. set default backup with purge by number 3 image
  2. if you wanna test it with cron, else skip this step
    • activate schedule in backup manager
    • activate schedule in schedules
  3. run the backup 4 times with: bin/grav scheduler -r default-site-backup
  4. you will get something like image
  5. you can run it via admin plugin, it will clean up to 3 backups (after page reload) image

Environment

OS: ubuntu 20.04.5 LTS CPU architecture: x86_64 How docker service was installed:

Command used to create docker container (run/create/compose/screenshot)

docker-compose up -d image

Thanks for any help.

thespad commented 2 years ago

Does anything show up in the logs? Absent anything suggesting otherwise, I'm inclined to think this is an upstream issue rather than a container one, as we don't do anything special around the backups, other than providing the necessary tools.

Although actually, if you're not already doing so can you try invoking the backup at the abc user (docker exec -u abc:abc) as it may be a simple permissions thing.

MrJack91 commented 2 years ago

Thanks for your answer! :) There is nothing special in docker logs grav. And it's the same with the user abc. It just works if I do it over the admin-panel.

nemchik commented 2 years ago

I am unable to reproduce this.

I followed the steps you listed:

  1. set default backup with purge by number 3

    I set it to 25. I was using space restriction previously and had 47

  2. if you wanna test it with cron, else skip this step
    • activate schedule in backup manager
    • activate schedule in schedules

      I did these steps

  3. run the backup 4 times with: bin/grav scheduler -r deafult-site-backup

    I did docker exec -it grav bash then cd /app/www/public;/usr/bin/php bin/grav scheduler -r default-site-backup which is formatted similar to the actual cron job that runs https://github.com/linuxserver/docker-grav/blob/4199effa3903cafea0215e367806c2588a64a2aa/root/etc/crontabs/abc#L2 but I also ran cd /app/www/public;bin/grav scheduler -r default-site-backup (only difference is removing /usr/bin/php

  4. you will get something like

    I did not see the results you saw (more backups than the allowed amount). I saw 25 (the amount I set).

  5. you can run it via admin plugin, it will clean up to 3 backups (after page reload)

    I ran another via admin and it showed 25 (expected)

It could be a difference in settings/configurations of grav itself, or it could be a bug, but I don't think it's a bug with the container (would be upstream).

Also, just to provide additional info, here is my /config/www/logs/grav.log

[2022-09-08 03:00:13] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220908030000.zip [] []
[2022-09-09 03:00:10] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220909030000.zip [] []
[2022-09-10 03:00:12] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220910030000.zip [] []
[2022-09-11 03:00:09] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220911030000.zip [] []
[2022-09-12 03:00:11] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220912030001.zip [] []
[2022-09-13 03:00:11] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220913030000.zip [] []
[2022-09-14 03:00:09] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220914030001.zip [] []
[2022-09-15 03:00:11] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220915030001.zip [] []
[2022-09-16 03:00:10] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220916030001.zip [] []
[2022-09-17 03:00:08] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220917030000.zip [] []
[2022-09-18 03:00:08] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220918030000.zip [] []
[2022-09-19 03:00:11] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220919030001.zip [] []
[2022-09-20 03:00:09] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220920030001.zip [] []
[2022-09-21 03:00:10] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220921030000.zip [] []
[2022-09-22 03:00:09] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220922030001.zip [] []
[2022-09-23 03:00:08] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220923030000.zip [] []
[2022-09-24 03:00:09] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220924030001.zip [] []
[2022-09-25 03:00:08] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220925030000.zip [] []
[2022-09-26 03:00:09] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220926030000.zip [] []
[2022-09-27 03:00:10] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220927030000.zip [] []
[2022-09-28 03:00:10] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220928030000.zip [] []
[2022-09-29 03:00:11] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220929030000.zip [] []
[2022-09-30 03:00:08] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20220930030000.zip [] []
[2022-10-01 03:00:08] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221001030000.zip [] []
[2022-10-02 03:00:08] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221002030000.zip [] []
[2022-10-03 03:00:11] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221003030000.zip [] []
[2022-10-04 03:00:09] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221004030000.zip [] []
[2022-10-04 08:10:32] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221004081025.zip [] []
[2022-10-04 08:15:29] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221004081522.zip [] []
[2022-10-04 08:16:11] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221004081605.zip [] []
[2022-10-04 08:18:36] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221004081831.zip [] []
[2022-10-04 08:29:49] grav.NOTICE: Backup Created: /app/www/public/backup/default_site_backup--20221004082944.zip [] []

Pretty much nothing in it but backups, the stuff prior to that was errors from when I was actively doing theme/plugin development. Anyway your log might have more information if something is happening differently.

MrJack91 commented 2 years ago

Hm. Ok, yes if I use a fresh container, it will be the same like you wrote. Everything works. Sorry for wasting your time.

Will figure out, what my problem is and publish my problem/solution here. Thanks for all your quick answers!