[PR #1939] [MERGED] feat: add --preserve-config flag to restore command #5344

Closed
opened 2026-04-16 13:34:45 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-vikunja/vikunja/pull/1939
Author: @kolaente
Created: 12/7/2025
Status: Merged
Merged: 12/7/2025
Merged by: @kolaente

Base: mainHead: preserve-config-restore


📝 Commits (2)

  • 2d5e3cc feat: add --preserve-config flag to restore command
  • 59c0692 fix: only show restart message when config was restored

📊 Changes

2 files changed (+16 additions, -6 deletions)

View changed files

📝 pkg/cmd/restore.go (+4 -1)
📝 pkg/modules/dump/restore.go (+12 -5)

📄 Description

Summary

Add a new --preserve-config flag to the restore command that allows users to restore database and files from a dump while keeping their existing configuration file untouched.

Motivation

Users may want to restore data from a dump without overwriting their current configuration. This is useful when:

  • Restoring data to a different environment with different settings (dev vs production)
  • Testing a restore without changing production configuration
  • Migrating data while maintaining environment-specific settings (different database hosts, file storage paths, service URLs, etc.)

Changes

  • Added --preserve-config boolean flag to the restore command
  • Updated dump.Restore() signature to accept an overrideConfig parameter
  • Added conditional logic to skip config restoration when flag is used
  • Added warning messages to alert users about potential config compatibility issues

Implementation Details

The flag uses clear semantics:

  • --preserve-config at CLI level (user-friendly)
  • overrideConfig parameter internally (positive logic, defaults to true for backward compatibility)
  • When --preserve-config is used, both config.yml and .env restoration are skipped

Testing

The implementation:

  • Maintains backward compatibility (default behavior unchanged)
  • Follows existing code patterns in the codebase
  • Includes appropriate warning messages to prevent misuse
  • Relies on existing error handling for config mismatches

Test Plan

  • Restore a dump without the flag (verify current behavior works)
  • Restore a dump with --preserve-config flag
  • Verify config file remains unchanged when flag is used
  • Verify database and files are still restored correctly
  • Verify appropriate warnings are displayed

🤖 Generated with Claude Code


🔄 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/go-vikunja/vikunja/pull/1939 **Author:** [@kolaente](https://github.com/kolaente) **Created:** 12/7/2025 **Status:** ✅ Merged **Merged:** 12/7/2025 **Merged by:** [@kolaente](https://github.com/kolaente) **Base:** `main` ← **Head:** `preserve-config-restore` --- ### 📝 Commits (2) - [`2d5e3cc`](https://github.com/go-vikunja/vikunja/commit/2d5e3cc3b634d70c1297395d4f417dd8dba3199a) feat: add --preserve-config flag to restore command - [`59c0692`](https://github.com/go-vikunja/vikunja/commit/59c0692f015c243afda0a7273029840320a5cfa9) fix: only show restart message when config was restored ### 📊 Changes **2 files changed** (+16 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `pkg/cmd/restore.go` (+4 -1) 📝 `pkg/modules/dump/restore.go` (+12 -5) </details> ### 📄 Description ## Summary Add a new `--preserve-config` flag to the restore command that allows users to restore database and files from a dump while keeping their existing configuration file untouched. ## Motivation Users may want to restore data from a dump without overwriting their current configuration. This is useful when: - Restoring data to a different environment with different settings (dev vs production) - Testing a restore without changing production configuration - Migrating data while maintaining environment-specific settings (different database hosts, file storage paths, service URLs, etc.) ## Changes - Added `--preserve-config` boolean flag to the restore command - Updated `dump.Restore()` signature to accept an `overrideConfig` parameter - Added conditional logic to skip config restoration when flag is used - Added warning messages to alert users about potential config compatibility issues ## Implementation Details The flag uses clear semantics: - `--preserve-config` at CLI level (user-friendly) - `overrideConfig` parameter internally (positive logic, defaults to `true` for backward compatibility) - When `--preserve-config` is used, both `config.yml` and `.env` restoration are skipped ## Testing The implementation: - Maintains backward compatibility (default behavior unchanged) - Follows existing code patterns in the codebase - Includes appropriate warning messages to prevent misuse - Relies on existing error handling for config mismatches ## Test Plan - [ ] Restore a dump without the flag (verify current behavior works) - [ ] Restore a dump with `--preserve-config` flag - [ ] Verify config file remains unchanged when flag is used - [ ] Verify database and files are still restored correctly - [ ] Verify appropriate warnings are displayed 🤖 Generated with [Claude Code](https://claude.com/claude-code) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-16 13:34:45 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/vikunja#5344