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

Broken backup flow if there's a config error #347

Open
alichtman opened this issue Jun 9, 2024 · 6 comments
Open

Broken backup flow if there's a config error #347

alichtman opened this issue Jun 9, 2024 · 6 comments

Comments

@alichtman
Copy link
Owner

dotfiles on  main took 1s
03:50:54 PM ➜ shallow-backup --backup-dots


              dP                dP dP                        dP                         dP
              88                88 88                        88                         88
     ,d8888'  88d888b. .d8888b. 88 88 .d8888b. dP  dP  dP    88d888b. .d8888b. .d8888b. 88  .dP  dP    dP 88d888b.
     Y8ooooo, 88'  `88 88'  `88 88 88 88'  `88 88  88  88    88'  `88 88'  `88 88'  `"" 88888"   88    88 88'  `88
           88 88    88 88.  .88 88 88 88.  .88 88.88b.88'    88.  .88 88.  .88 88.  ... 88  `8b. 88.  .88 88.  .88
     `88888P' dP    dP `88888P8 dP dP `88888P' 8888P Y8P     88Y8888' `88888P8 `88888P' dP   `YP `88888P' 88Y888P'
                                                                                                          88
                                                                                                          dP
        v6.3a by Aaron Lichtman (@alichtman)

Detected git repo.
Updating .gitignore file at /home/alichtman/shallow-backup/.gitignore with config from root-gitignore
Updating .gitignore file at /home/alichtman/shallow-backup/dotfiles/.gitignore with config from dotfiles-gitignore

##########
# DOTFILES
##########

Backing up dotfolders...
Backing up dotfiles...
Error copying: /home/alichtman/.config/agignore
 -> This may mean you have an error in your config.
Error copying: /home/alichtman/.config/crontab
 -> This may mean you have an error in your config.
Error copying: /home/alichtman/.config/nvim-old
 -> This may mean you have an error in your config.









[?] If you do not, the parent repo will not be able to commit the dotfile changes...:
 >  Yes
    No


Cancelled by user


@omarluq
Copy link

omarluq commented Jun 15, 2024

Having the same issue, any hacks around this?

@alichtman
Copy link
Owner Author

alichtman commented Jun 15, 2024

Arguably, you should not be hacking around it. You should fix your config file to not have errors (in my case, I was attempting to back up files that no longer exist).

I don't think this should silently succeed -- it probably indicates your backup isn't doing what you think it is.

The details I added in the issue are sparse, but my intent is to make this error hard, so you must fix the config if you want to run a backup.

@zirkelc
Copy link

zirkelc commented Oct 1, 2024

What kind of issues will be detected by shallow-backup? I get the following errors:

Error copying: /Users/zirkelc/.bash_profile
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/git
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/nvim/init.vim
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/tmux
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/zsh
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.pypirc
 -> This may mean you have an error in your config.

For example, what exactly does Error copying: /Users/zirkelc/.config/git mean? The file ~/.config/git doesn't exist, but the actual git config is located at ~/.gitconfig.

Maybe I'm misunderstanding something?

@alichtman
Copy link
Owner Author

Based on the details you provided, it sounds like the "error" here is that you have paths that don't exist on your machine in the config (they're populated by default). I'd suggest fixing this by editing the shallow backup config file to backup the files that do exist.

The error message could probably be improved, but I haven't been able to prioritize it.

@zirkelc
Copy link

zirkelc commented Oct 2, 2024

I deleted the ~/shallow-backup folder and the ~/.config/shallow-backup.json, then run shallow backup again:

Here's the output:

Current shallow-backup path: ~/shallow-backup
[?] Would you like to move this somewhere else?: 
 >  No
    Yes

Created directory: /Users/zirkelc/shallow-backup
Initializing new git repo...
Updating .gitignore file at /Users/zirkelc/shallow-backup/.gitignore with config from root-gitignore
WARNING: If you back up to a public remote, make sure no sensitive files are included by modifying the .gitignore.
[?] Would you like to set a remote URL for this git repo?: 
 >  Yes
    No

Enter URL:
https://github.com/zirkelc/shallow-backup.git
Setting remote URL to: https://github.com/zirkelc/shallow-backup.git...
Updating .gitignore file at /Users/zirkelc/shallow-backup/dotfiles/.gitignore with config from dotfiles-gitignore
[?] What would you like to do?: 
 >  Back up all
    Back up configs
    Back up dotfiles
    Back up fonts
    Back up packages
    Reinstall all
    Reinstall configs
    Reinstall dotfiles
    Reinstall fonts
    Reinstall packages
    Add path to config
    Remove path from config
    Edit config


##########
# DOTFILES
##########

Directory already exists: /Users/zirkelc/shallow-backup/dotfiles
[?] Erase directory and make new back up?: 
 >  Yes
    No

Backing up dotfolders...
Backing up dotfiles...
Error copying: /Users/zirkelc/.bash_profile
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/git
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/nvim/init.vim
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/tmux
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.config/zsh
 -> This may mean you have an error in your config.
Error copying: /Users/zirkelc/.pypirc
 -> This may mean you have an error in your config.

##########
# PACKAGES
##########

Created directory: /Users/zirkelc/shallow-backup/packages
Backing up brew packages list...
Backing up gem packages list...
Backing up cargo packages list...
Backing up pip packages list...
An error occurred while running: $ pip list --format=freeze
Backing up pip3 packages list...
Backing up npm packages list...
Backing up VSCode packages list...
Backing up macports packages list...
An error occurred while running: $ port installed requested
Backing up System Applications packages list...

#######
# FONTS
#######

Created directory: /Users/zirkelc/shallow-backup/fonts
Copying '.otf' and '.ttf' fonts...

#########
# CONFIGS
#########

Created directory: /Users/zirkelc/shallow-backup/configs
Backing up configs...
Checking for separate git repo in dotfiles directory...
No nested dotfiles repo detected.
Adding pre-commit config file...
pre-commit installed at .git/hooks/pre-commit
No changes to commit...

Is tehre another config to delete?

@alichtman
Copy link
Owner Author

alichtman commented Oct 2, 2024

If you delete the config file, shallow-backup will create a brand new default config for you:

https://github.com/alichtman/shallow-backup/blob/main/shallow_backup/config.py#L57-L103

If you want to change the specific paths that are backed up, you need to edit the config file (not delete it).

Please see the documentation here: https://github.com/alichtman/shallow-backup#configuration

the actual git config is located at ~/.gitconfig

For some explanation on the defaults: In my opinion, this is the wrong place to store a global git config file. It should be under ~/.config/git, abiding by the XDG Base Dir Spec: https://maex.me/2019/12/the-power-of-the-xdg-base-directory-specification/

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

No branches or pull requests

3 participants