How to clean files older than n days ? #567
-
Feature descriptionI'm configuring Django dbbackup for a client application using celery. I'm using this code to start the backup: import datetime
from celery import shared_task
from django.conf import settings
from django.core.management import call_command
@shared_task
def backup_database_each_quarter():
# if settings.DEBUG is True:
# return f"Could not be backed up: Debug is True"
try:
call_command( "dbbackup", "-c", "--noinput" )
return f"Backed up successfully: {datetime.datetime.now()}"
except Exception as err:
raise BaseException('Cannot be backed up : {}'.format(err)) During my morning check I noticed that the old 2GB db backup files are not being deleted. If I can't delete the old files generated, the server will run out of space. I was wondering if something like this could be added to the codebase, a management command that just deletes the previous backup files. Otherwise, if you are adding new features, I would like to add this command that might help me or others with the same problem to solve it. Alternatives optionsNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
This feature already exists See the documentation for |
Beta Was this translation helpful? Give feedback.
This feature already exists See the documentation for
DBBACKUP_CLEANUP_KEEP
https://django-dbbackup.readthedocs.io/en/stable/configuration.html#dbbackup-cleanup-keep-and-dbbackup-cleanup-keep-media