django-dbbackup
django-dbbackup copied to clipboard
"--clean" flag not working as expected
Describe the bug
The --clean
flag gracefully ignoring the DBBACKUP_CLEANUP_KEEP
value
To Reproduce
# settings.py
DBBACKUP_STORAGE = 'django.core.files.storage.FileSystemStorage'
DBBACKUP_DEFAULT_SERVER_NAME = env("DBBACKUP_DEFAULT_SERVER_NAME", default="localhost")
def backup_filename(databasename, servername, datetime, extension, content_type):
servername = DBBACKUP_DEFAULT_SERVER_NAME or servername
directory = f"{DBBACKUP_PREFIX}/{databasename}"
file_name = f"{servername}-{datetime}.{extension}"
return f"{directory}/{file_name}"
DBBACKUP_FILENAME_TEMPLATE = backup_filename
DBBACKUP_CLEANUP_KEEP = 2
DBBACKUP_PREFIX = "test-prefix"
# terminal output
╰(generic-django-example-Kc6WXfau)─λ ls -al test-prefix/default/ 0 (0.864s) < 09:20:29
total 384
drwxrwxrwx 1 root root 4096 Apr 19 09:20 ./
drwxrwxrwx 1 root root 0 Apr 19 09:19 ../
-rwxrwxrwx 1 root root 74585 Apr 19 09:19 localhost-2023-04-19-034951.psql.bin*
-rwxrwxrwx 1 root root 74585 Apr 19 09:20 localhost-2023-04-19-035022.psql.bin*
-rwxrwxrwx 1 root root 74585 Apr 19 09:20 localhost-2023-04-19-035024.psql.bin*
-rwxrwxrwx 1 root root 74585 Apr 19 09:20 localhost-2023-04-19-035026.psql.bin*
-rwxrwxrwx 1 root root 74585 Apr 19 09:20 localhost-2023-04-19-035028.psql.bin*
Expected behavior
The test-prefix/default/
directory should only contain files equal to the value of DBBACKUP_CLEANUP_KEEP
Versions
Django-dbbackup
- django-dbbackup==4.0.2
External tools
- Python 3.9.11
- Django 3.2.18
- OS: Linux