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

restic snapshots exit code check #53

Open
avgeeklucky opened this issue Jul 23, 2020 · 3 comments
Open

restic snapshots exit code check #53

avgeeklucky opened this issue Jul 23, 2020 · 3 comments

Comments

@avgeeklucky
Copy link

This has caused me problems:

restic snapshots &>/dev/null
status=$?
echo "Check Repo status $status"
if [ $status != 0 ]; then
echo "Restic repository '${RESTIC_REPOSITORY}' does not exists. Running restic init."
restic init
init_status=$?
echo "Repo init status $init_status"
if [ $init_status != 0 ]; then
echo "Failed to init the repository: '${RESTIC_REPOSITORY}'"
exit 1
fi
fi

Specifically, I've had backups be interrupted mid process (post backup cleanup or the backup it self, not sure) and they have locked the repository, causing restic snapshots to return a non 0 exit code, next the entry script tries to init a new repository which fails because it's already there. Because I've got restart=always, the container ends up in a restart loop.

I'm not sure how to fix this since restic does not provide meaningful exit codes (restic/restic#956). String parsing is not a great idea either...

@bruno-lopes
Copy link

I detected the same problem here. Perhaps it would be nice to use the following command

restic --no-lock list locks

This way it is possible to detect logs and provide a meaningful message to warn the user about the problem.

@niondir
Copy link
Member

niondir commented Dec 28, 2020

Sounds good. Feel free to provide a PR.

@wuast94
Copy link

wuast94 commented Jan 16, 2021

have the error too and all my backups cant start anymore :/

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

4 participants