autorestic icon indicating copy to clipboard operation
autorestic copied to clipboard

fix: cli command to unlock the autorestic running value

Open rwxd opened this issue 2 years ago • 3 comments

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.

rwxd avatar Oct 10 '23 18:10 rwxd

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

vercel[bot] avatar Oct 10 '23 18:10 vercel[bot]

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?

cupcakearmy avatar Oct 10 '23 18:10 cupcakearmy

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

rwxd avatar Oct 10 '23 19:10 rwxd

@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):

bin101 avatar Mar 12 '24 14:03 bin101