Skip to content

How to clean files older than n days ? #552

Open
@manutheblacker

Description

@manutheblacker

Feature description

I'm configuring Django dbbackup for a client application using celery.
I've been able to create a worker that starts a task that backs up the whole app 2 times a day.

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 options

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions