https://github.com/dani-garcia/vaultwarden/pull/6279 introduced several great improvements, but replaced VACUUM INTO with serialize_database_to_buffer() which is less efficient and loads the whole DB into RAM. This may be contributing to an increase in OOM errors which I have noticed in small vaultwarden deployments with 256MB RAM.
This PR reverts the serialize_database_to_buffer() change back into a VACUUM INTO query while keeping the other improvements from that PR. I also used .bind::<Text, _>(&backup_file) instead of the previous format!("VACUUM INTO '{}'", backup_file) to prevent theoretical SQL injection (even though path is trusted), let me know if you prefer the format! approach and I can switch it
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/dani-garcia/vaultwarden/pull/6989
**Author:** [@getaaron](https://github.com/getaaron)
**Created:** 3/22/2026
**Status:** ✅ Merged
**Merged:** 4/5/2026
**Merged by:** [@dani-garcia](https://github.com/dani-garcia)
**Base:** `main` ← **Head:** `fix-backup-memory`
---
### 📝 Commits (2)
- [`668f1bd`](https://github.com/dani-garcia/vaultwarden/commit/668f1bdedfe5eac485925ce871e9ecf86dd69d23) Refactor SQLite backup to use VACUUM INTO query
- [`717ebfb`](https://github.com/dani-garcia/vaultwarden/commit/717ebfbf89731904f128a03dde95c11c7f41dae0) Fix VACUUM INTO query error handling
### 📊 Changes
**1 file changed** (+7 additions, -11 deletions)
<details>
<summary>View changed files</summary>
📝 `src/db/mod.rs` (+7 -11)
</details>
### 📄 Description
https://github.com/dani-garcia/vaultwarden/pull/6279 introduced several great improvements, but replaced `VACUUM INTO` with `serialize_database_to_buffer()` which is less efficient and loads the whole DB into RAM. This may be contributing to an increase in OOM errors which I have noticed in small vaultwarden deployments with 256MB RAM.
This PR reverts the `serialize_database_to_buffer()` change back into a `VACUUM INTO` query while keeping the other improvements from that PR. I also used `.bind::<Text, _>(&backup_file)` instead of the previous `format!("VACUUM INTO '{}'", backup_file)` to prevent theoretical SQL injection (even though path is trusted), let me know if you prefer the `format!` approach and I can switch it
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/dani-garcia/vaultwarden/pull/6989
Author: @getaaron
Created: 3/22/2026
Status: ✅ Merged
Merged: 4/5/2026
Merged by: @dani-garcia
Base:
main← Head:fix-backup-memory📝 Commits (2)
668f1bdRefactor SQLite backup to use VACUUM INTO query717ebfbFix VACUUM INTO query error handling📊 Changes
1 file changed (+7 additions, -11 deletions)
View changed files
📝
src/db/mod.rs(+7 -11)📄 Description
https://github.com/dani-garcia/vaultwarden/pull/6279 introduced several great improvements, but replaced
VACUUM INTOwithserialize_database_to_buffer()which is less efficient and loads the whole DB into RAM. This may be contributing to an increase in OOM errors which I have noticed in small vaultwarden deployments with 256MB RAM.This PR reverts the
serialize_database_to_buffer()change back into aVACUUM INTOquery while keeping the other improvements from that PR. I also used.bind::<Text, _>(&backup_file)instead of the previousformat!("VACUUM INTO '{}'", backup_file)to prevent theoretical SQL injection (even though path is trusted), let me know if you prefer theformat!approach and I can switch it🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.