Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-3240] Shrink the database transaction logs after backup #3140

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

zadjadr
Copy link

@zadjadr zadjadr commented Jul 28, 2023

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

Without shrinking the transaction log, mssql will keep them indefinitely.

This would generate a huge log file after some time.
@CLAassistant
Copy link

CLAassistant commented Jul 28, 2023

CLA assistant check
All committers have signed the CLA.

@bitwarden-bot
Copy link

Thank you for your contribution! We've added this to our internal Community PR board for review.
ID: PM-3240

@bitwarden-bot bitwarden-bot changed the title Shrink the database transaction logs after backup [PM-3240] Shrink the database transaction logs after backup Jul 28, 2023
@bitwarden-bot
Copy link

Logo
Checkmarx One – Scan Summary & Details0da55a2a-e37e-423c-8fc8-6d9d177fb10f

No New Or Fixed Issues Found

@zadjadr
Copy link
Author

zadjadr commented Aug 21, 2023

Fixes #648

@pocoloko
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants