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

nixos/vaultwarden: backup all rsa_keys #318347

Merged
merged 1 commit into from
Jun 25, 2024

Conversation

caffineehacker
Copy link
Contributor

The official documentation mentions rsa_key* as what should be backed up (https://github.com/dani-garcia/vaultwarden/wiki/Backing-up-your-vault#the-rsa_key-files). My particular install has rsa_key.pem and rsa_key.pub.pem so the existing command fails when trying to copy rsa_key.der. This change better aligns with the official documentation.

Description of changes

This is a simple change to just copy all rsa_key.* files instead of specific extensions. This commit to vaultwarden actually removed the use of .der files: dani-garcia/vaultwarden@46e0f3c

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@caffineehacker
Copy link
Contributor Author

@dotlambda @SuperSandro2000 looks like this didn't get auto assigned

@SuperSandro2000
Copy link
Member

My particular install has rsa_key.pem and rsa_key.pub.pem so the existing command fails when trying to copy rsa_key.der. This change better aligns with the official documentation.

same for mine

Copy link
Member

@SuperSandro2000 SuperSandro2000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dotlambda
Copy link
Member

Why don't we backup sends and config.json?

@caffineehacker
Copy link
Contributor Author

Why don't we backup sends and config.json?

We probably should, but note that config.json is only there if the user has changed settings via the admin page (I think, may get created in other ways, but it won't be in every install). We should probably do a command that copies everything in data except the sqlite files. I can take a look at making that work tomorrow.

@SuperSandro2000
Copy link
Member

Lets merge #292857 first, to know if the backups work at all.

cp -r "$DATA_FOLDER"/attachments "$BACKUP_FOLDER"
if [[ -e "$DATA_FOLDER"/config.json ]]; then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SuperSandro2000 What are your thoughts on doing the same logic before doing the sqlite dump? Technically this backup script could be used with another backing DB (although a lot less useful). I know the script still continues executing, but it does produce error messages in the logs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure, why not

@SuperSandro2000
Copy link
Member

Can you rebase to draw in the above PR and adjust the test accordingly? That would be awesome

@caffineehacker caffineehacker force-pushed the vaultwarden_backup branch 2 times, most recently from 9dd7384 to 57cac1d Compare June 16, 2024 03:30
The official documentation mentions rsa_key* as what should be backed up (https://github.com/dani-garcia/vaultwarden/wiki/Backing-up-your-vault#the-rsa_key-files). My particular install has rsa_key.pem and rsa_key.pub.pem so the existing command fails when trying to copy rsa_key.der. This change better aligns with the official documentation.
@caffineehacker
Copy link
Contributor Author

Can you rebase to draw in the above PR and adjust the test accordingly? That would be awesome

Done. I've done some further refinements which should reduce unnecessary errors. I'm on the fence as to whether not having the script return code 0 if the data directory doesn't exist is the right thing or not. It doesn't fail the tests to not have it, but it does show up in red during testing and in the journald logs.

@caffineehacker
Copy link
Contributor Author

Please let me know if there is anything else waiting on me before this can be merged. No rush, just want to make sure I didn't miss an action item.

@SuperSandro2000 SuperSandro2000 merged commit 5b0ea75 into NixOS:master Jun 25, 2024
22 checks passed
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