server
server copied to clipboard
[PM-3240] Shrink the database transaction logs after backup
Type of change
- [X] Bug fix
- [ ] New feature development
- [ ] Tech debt (refactoring, code cleanup, dependency upgrades, etc)
- [ ] Build/deploy pipeline (DevOps)
- [ ] Other
Objective
Without shrinking the transaction logs, mssql will keep them indefinitely. This would generate a huge log file after some time. In my case this is 27GB
Code changes
Most important change is adding
- backup-db.sh: DBCC SHRINKFILE ('$(DATABASE_NAME)_log', EMPTYFILE);
According to https://learn.microsoft.com/de-de/sql/t-sql/database-console-commands/dbcc-shrinkfile-transact-sql?view=sql-server-ver16
- file.ext: Description of what was changed and why
Before you submit
- Please check for formatting errors (
dotnet format --verify-no-changes) (required) - If making database changes - make sure you also update Entity Framework queries and/or migrations
- Please add unit tests where it makes sense to do so (encouraged but not required)
- If this change requires a documentation update - notify the documentation team
- If this change has particular deployment requirements - notify the DevOps team
Thank you for your contribution! We've added this to our internal Community PR board for review. ID: PM-3240
Checkmarx One – Scan Summary & Details – 0da55a2a-e37e-423c-8fc8-6d9d177fb10f
No New Or Fixed Issues Found
Fixes https://github.com/bitwarden/server/issues/648
surprised this hasn't been fixed yet, my vault_log.ldf file is 2.3GB which sure doesn't seem like a lot in this day and age but it is running on a low end VPS with limited storage so in the end I have to regularly delete backup files to not run out of space