Skip to content

Fix Compression of DjangoConnector Backups#667

Merged
Archmonger merged 7 commits intoArchmonger:masterfrom
Roukoswarf:fix/djangoconnector-compress
Apr 8, 2026
Merged

Fix Compression of DjangoConnector Backups#667
Archmonger merged 7 commits intoArchmonger:masterfrom
Roukoswarf:fix/djangoconnector-compress

Conversation

@Roukoswarf
Copy link
Copy Markdown
Contributor

@Roukoswarf Roukoswarf commented Apr 7, 2026

Description

The DjangoConnector returned a text-mode file, which made the compression code which expected binary as is returned from other connectors to crash with:

  File "/opt/infradesigner/.venv/lib/python3.14/site-packages/dbbackup/management/commands/dbbackup.py", line 143, in _save_new_backup
    compressed_file, filename = utils.compress_file(outputfile, filename)
                                ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/infradesigner/.venv/lib/python3.14/site-packages/dbbackup/utils.py", line 271, in compress_file
    copyfileobj(inputfile, zipfile, settings.TMP_FILE_READ_SIZE)
    ~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.14/shutil.py", line 257, in copyfileobj
    fdst_write(buf)
    ~~~~~~~~~~^^^^^
  File "/usr/lib/python3.14/gzip.py", line 321, in write
    return self._buffer.write(data)
           ~~~~~~~~~~~~~~~~~~^^^^^^
TypeError: a bytes-like object is required, not 'str'

Tests don't seem to cover this combination, maybe I will have time to write tests for this, but for now I just needed this fixed for myself.

This also accidentally seems to fix an issue paramiko (SFTP Storage) was having where the os.stat(). Sizes were always larger on the target host vs the source, though the file seemed correct. Did not investigate much, but I suspect it also could be related to utf8 vs on-disk size.

Checklist

Please update this checklist as you complete each item:

  • Tests have been developed for bug fixes or new functionality.
  • The changelog has been updated, if necessary.
  • Documentation has been updated, if necessary.
  • GitHub Issues closed by this PR have been linked.

By submitting this pull request I agree that all contributions comply with this project's open source license(s).

@Archmonger Archmonger merged commit 045a688 into Archmonger:master Apr 8, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants