Skip to content

feat(backend): ensure restore of backups only works in correct enviroments#11372

Merged
SchrodingersGat merged 19 commits intoinventree:masterfrom
matmair:matmair/issue11214
Feb 24, 2026
Merged

feat(backend): ensure restore of backups only works in correct enviroments#11372
SchrodingersGat merged 19 commits intoinventree:masterfrom
matmair:matmair/issue11214

Conversation

@matmair
Copy link
Member

@matmair matmair commented Feb 18, 2026

This uses a new function I upstreamed in dbbackup to allow us checking various environment markers.
The names of variables are chosen in a manner to keep long-term restore compatibility in place as we might evolve this schema. It is no rocket science but should help with some common issues, especially if we get logs for debugging.

To-do:

  • add error codes?
  • docs
  • flag to allow a dangerous restore
  • e2e test?

Fixes #11214

@matmair matmair added this to the 1.3.0 milestone Feb 18, 2026
@matmair matmair self-assigned this Feb 18, 2026
@matmair matmair added enhancement This is an suggested enhancement or new feature setup Relates to the InvenTree setup / installation process labels Feb 18, 2026
@netlify
Copy link

netlify bot commented Feb 18, 2026

Deploy Preview for inventree-web-pui-preview ready!

Name Link
🔨 Latest commit 21e402f
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/699e0d21426b4d0008455f04
😎 Deploy Preview https://deploy-preview-11372--inventree-web-pui-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 93 (no change from production)
Accessibility: 81 (no change from production)
Best Practices: 100 (no change from production)
SEO: 78 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify project configuration.

@matmair matmair changed the title [FR] ensure restore of backups only works in correct enviroments feat(backend): ensure restore of backups only works in correct enviroments Feb 18, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Feb 18, 2026

Merging this PR will improve performance by 11.3%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚡ 7 improved benchmarks
✅ 37 untouched benchmarks

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime test_search_performance[stockitem] 108 ms 100 ms +8.05%
WallTime test_api_options_performance[/api/order/po-line/] 154 ms 142.5 ms +8.11%
WallTime test_search_performance[build] 35 ms 32.6 ms +7.44%
WallTime test_api_list_performance[/api/build/item/] 316.6 ms 291.3 ms +8.68%
WallTime test_api_options_performance[/api/build/line/] 392.4 ms 352.6 ms +11.3%
WallTime test_api_options_performance[/api/build/item/] 320.8 ms 294.1 ms +9.1%
WallTime test_api_options_performance[/api/order/so/] 53.9 ms 50.7 ms +6.44%

Comparing matmair:matmair/issue11214 (21e402f) with master (246108e)1

Open in CodSpeed

Footnotes

  1. No successful run was found on master (8a4ad4f) during the generation of this report, so 246108e was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

❌ Patch coverage is 99.12281% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 88.02%. Comparing base (8a4ad4f) to head (21e402f).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #11372      +/-   ##
==========================================
+ Coverage   87.99%   88.02%   +0.02%     
==========================================
  Files        1295     1295              
  Lines       58793    58917     +124     
  Branches     1938     1941       +3     
==========================================
+ Hits        51733    51859     +126     
+ Misses       6578     6574       -4     
- Partials      482      484       +2     
Flag Coverage Δ
backend 89.20% <99.12%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 91.69% <ø> (ø)
Backend General 93.37% <ø> (ø)
Frontend 70.82% <ø> (+0.01%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@matmair matmair marked this pull request as ready for review February 24, 2026 20:58
@SchrodingersGat
Copy link
Member

Nice work, and great job getting the functionality merged upstream.

dbbackup version

Have we already updated to the required version of django-dbbackup? There is no version bump in this PR?

docs

It would be great to add a brief paragraph to the backup docs regarding compatibility

@matmair
Copy link
Member Author

matmair commented Feb 24, 2026

Have we already updated to the required version of django-dbbackup? There is no version bump in this PR?

yes, that was included in the latest bump (5.2.0 included the change)

It would be great to add a brief paragraph to the backup docs regarding compatibility

This PR mostly prevents footguns, there is no functional change other than (by default) stopping restores from newer versions. I will add a short section on some basic restrictions. Real world functional decencies will probably only enter with #11235

@SchrodingersGat SchrodingersGat merged commit ac9a1f2 into inventree:master Feb 24, 2026
54 of 55 checks passed
@SchrodingersGat SchrodingersGat deleted the matmair/issue11214 branch February 24, 2026 23:23
@SchrodingersGat
Copy link
Member

@matmair fair enough - if you can submit some brief docs too that would be great, but happy to merge this now

jmerro-c3d pushed a commit to jmerro-c3d/InvenTree that referenced this pull request Feb 25, 2026
…ments (inventree#11372)

* [FR] ensure restore of backups only works in correct enviroments
Fixes inventree#11214

* update PR nbr

* fix wrong ty detection

* fix link

* ensure tracing does not enagage while running backup ops

* fix import

* remove debugging string

* add error codes

* add tests for backup and restore

* complete test for restore

* we do not need e2e on every matrix entry
there is no realy db dep here

* fix changelog format

* add flag to allow bypass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement This is an suggested enhancement or new feature setup Relates to the InvenTree setup / installation process

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FR] ensure restore of backups only works in correct enviroments

2 participants