cupcakearmy / autorestic

Config driven, easy backup cli for restic.
https://autorestic.vercel.app/
Apache License 2.0
1.16k stars 68 forks source link

fix: cli command to unlock the autorestic running value #329

Closed rwxd closed 3 months ago

rwxd commented 8 months ago

Hi, thanks for the awesome tool.

I had the case where the .autorestic.lock.yml had the running key to true but there was no instance running.

This pull request adds the unlock command which just unlocks. Additionally a page to the documentation is added.

Example:

❯ go run main.go unlock
Using config:    /home/user/.autorestic.yaml
Using lock:      /home/user/.autorestic.lock.yml
Unlock successful
❯ cat ~/.autorestic.lock.yml | grep running
running: false

I don't know if "fix:" is the right commit, I can rewrite the commit with "feat:" in case it fits better.

vercel[bot] commented 8 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
autorestic ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 10, 2023 7:26pm
cupcakearmy commented 8 months ago

super cool, thanks :) In the docs you already showed how to check if autorestic is running, do we want to add that check into the code itself?

rwxd commented 8 months ago

super cool, thanks :) In the docs you already showed how to check if autorestic is running, do we want to add that check into the code itself?

That is a good idea.

I modified the source code a bit so that the running processes will be checked. In case there is an autorestc process running, the user will get warned and has the option to abort or write yes to still unlock the lock.

No process running

❯ go run main.go unlock
Using config:    /home/user/.autorestic.yaml
Using lock:      /home/user/.autorestic.lock.yml
Unlock successful

Process running, aborting with no

❯ go run main.go unlock
Using config:    /home/user/.autorestic.yaml
Found autorestic processes:
root       61997  0.0  0.0 1236056 7472 pts/7    Sl+  20:45   0:00 autorestic --ci backup -a
Another autorestic instance is running. Are you sure you want to unlock? (yes/no): no
Unlocking aborted.

Processing running, continue with yes

❯ go run main.go unlock
Using config:    /home/user/.autorestic.yaml
Found autorestic processes:
root       61997  0.0  0.0 1236056 7472 pts/7    Sl+  20:45   0:00 autorestic --ci backup -a
Another autorestic instance is running. Are you sure you want to unlock? (yes/no): yes
Using lock:      /home/user/.autorestic.lock.yml
Unlock successful
bin101 commented 3 months ago

@rwxd @cupcakearmy The unlock check now also detects the unlock process, e.g.:

❯ autorestic unlock
Using config:    /root/.autorestic.yml
Found autorestic processes:
root     2834763  0.0  0.0 1232972 5632 pts/0    Sl+  15:51   0:00 autorestic unlock
Another autorestic instance is running. Are you sure you want to unlock? (yes/no):