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

provide a --backup parameter for apply cmd #4194

Open
parisni opened this issue Jan 9, 2025 · 0 comments
Open

provide a --backup parameter for apply cmd #4194

parisni opened this issue Jan 9, 2025 · 0 comments
Labels
enhancement New feature or request

Comments

@parisni
Copy link

parisni commented Jan 9, 2025

Is your feature request related to a problem? Please describe.

I was in the process of migrating from no dotfile manager to chezmoi on two laptops.

  1. I used ch add files on first laptop
  2. I cloned the config on second laptop and templated the files to handle the config diff
  3. The diff became very difficult to read and I could not apply with 100% trust, so I did backup existing files on second laptop (added .back on every files managed by chezmoi) and then applied
  4. Turns out I broke some files (lost few lines) then I was happy to have the backup

I would find useful to provide a built-in --backup parameter to let chezmoi do itself the backup for every single file it would overwrite.

WDYT ?

EDIT: used that command to dump files before apply

chd |awk '/diff --/{gsub(/a\//, "", $3);gsub(/.*/,"cp " $3 " " $3 ".back",$3);print $3;system($3)}'
@parisni parisni added the enhancement New feature or request label Jan 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant