andrewchambers / bupstash

Easy and efficient encrypted backups.
https://bupstash.io
MIT License
897 stars 31 forks source link

pwd in .zshrc #361

Closed akyag closed 1 year ago

akyag commented 1 year ago

Hello, thank you for this awesome tool. I am a borg user and currently testing bupstash and I love it so far.

I have export BUPSTASH_REPOSITORY="$(pwd)/bupstash-repo" in my .zshrc. My repo's path is /mnt/data/archives/bupstash/code If I open the repo in file manager and do a bupstash list it works. But If I open the terminal and travel to this path and try the same command it gives me error as following.

➜ ~ 
➜ ~ /mnt/data/archives/bupstash/code     
➜ /mnt/data/archives/bupstash/code bupstash list
bupstash serve: unable to open repository at /home/akya/bupstash-repo: No such file or directory (os error 2)
bupstash list: remote disconnected
➜ /mnt/data/archives/bupstash/code echo $BUPSTASH_REPOSITORY
/home/akya/bupstash-repo

If I open the directory in file manager >> open terminal here, I get

➜ /mnt/data/archives/bupstash/code bupstash list
id="6e8c2e90370779b8a9327e61b8066a3f" name="code-backup.tar" size="2.63GiB" tag="daily" timestamp="2022/12/06 15:04:28"
id="2b011281674eaf84720757a764e294fe" name="code-backup.tar" size="2.62GiB" tag="daily" timestamp="2022/12/06 15:09:50"
id="4cc85e5ea9c048e05709769ce1f17160" name="code-backup.tar" size="2.53GiB" tag="weekly" timestamp="2022/12/09 08:58:39"
➜ /mnt/data/archives/bupstash/code echo $BUPSTASH_REPOSITORY
/mnt/data/archives/bupstash/code/bupstash-repo

As I was writing this I realized I could just source the .zshrc again once in that directory and that works. but is this how bupstash is designed? If I run a bupstash command, shouldn't it take the working directory as a repo? for ex, if I have a borg repo, to list the backups I can just go into the repo and do a borg list .

andrewchambers commented 1 year ago

I think your problem is your $(pwd) value is changing based on how you are launching your terminal - I would recommend just putting an absolute path or a path relative to $HOME instead of a path relative to the $(pwd) of the program launching your terminal. Bupstash just treats BUPSTASH_REPOSITORY as a path relative to its working directory or as an absolute path if you specified one.

Also, If I am understanding correctly, you could use BUPSTASH_REPOSITORY="." or pass -r . to get behavior similar to what you see with borg.

akyag commented 1 year ago

Thank you, I added

export BUPSTASH_REPOSITORY="bupstash-repo"
export BUPSTASH_KEY=/home/akya/backups.key

this to my .zshrc and now it works as I want. So in scripts I can use absolute path for repos and when checking backups I just go to the repo and can do bupstash list and it works correctly. I will keep testing further.. Thanks again.