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

Feature Request: Automatic Backup and Recovery for db.zo #807

Open
hoofcushion opened this issue May 2, 2024 · 6 comments
Open

Feature Request: Automatic Backup and Recovery for db.zo #807

hoofcushion opened this issue May 2, 2024 · 6 comments

Comments

@hoofcushion
Copy link

I encountered an issue with zoxide where I had to delete db.zo due to a database file corruption error: zoxide: unsupported version (got 0, supports 3).

That will fix the error, but all data are lost, so I have to type all of the file path again.

It would be helpful if zoxide could automatically create backups of db.zo and have a recovery option for corrupted or incompatible database files.

This feature would improve the resilience of the tool and save users from manual intervention in case of database errors.

Thank you for considering this request.

@josephwhite
Copy link

josephwhite commented May 2, 2024

First problem that would need to be addressed is just importing Zoxide's own format (#591).

For PowerShell users, the workaround that I have been using is querying the entire database, converting to an object, formatting the object to a string array to match the format of Z/Autojump, and then writing that to a file. From here, it would be up to the user on how they would want to handle their backups.

@hoofcushion
Copy link
Author

hoofcushion commented May 2, 2024

@josephwhite Even though we don't have the final format for db.zo, zoxide could still back it up. Maybe make a copy named db.zo.bak. If there's a problem occurred for loading db.zo, zoxide could try to use the backup or just tell user themselves to recovery it. This way, users won't lose their data, and it doesn't depend on a specific data format. What do you think?

@hoofcushion
Copy link
Author

I have a temporary workaround of making a copy of db.zo named db.zo.bak every time I call zoxide success, by configure the command z's behavior.

@wswslzp
Copy link

wswslzp commented May 14, 2024

I have a temporary workaround of making a copy of db.zo named db.zo.bak every time I call zoxide success, by configure the command z's behavior.

Hi @hoofcushion can you share your WAR here?

@hoofcushion
Copy link
Author

hoofcushion commented May 15, 2024

@wswslzp Here's my ~/.bashrc

if test -n $(command -v zoxide); then
 eval "$(zoxide init $(basename $SHELL))"
 function back() {
  local command="$1"
  shift
  "${command}" "$@"
  if [ $? -eq 0 ]; then
   cp "$HOME/.local/share/zoxide/db.zo" "$HOME/.local/share/zoxide/db.zo.bak"
  fi
 }
 alias cd='back z'
 alias cdi='back zi'
fi

And what does WAR means?

@wswslzp
Copy link

wswslzp commented May 16, 2024 via email

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