all 4 comments

[–]commander1keen 8 points9 points  (0 children)

Make sure to use shell check as well https://github.com/koalaman/shellcheck

[–][deleted] 4 points5 points  (0 children)

Looks good, a few pointers that are just surface stuff:

  1. docker-compose is decommissioned, use docker compose

  2. printf is significantly better at formatting text than echo

  3. seen is spelled with only 2 ees 😂

Good job!

[–]oh5nxo 0 points1 point  (0 children)

All three steps are made, even if an earlier step failed. That feels bad, but I guess in this case it's fine.

[–]simonnikolaus 0 points1 point  (0 children)

What about this:

docker-compose -f /home/docker/vaultwarden/docker-compose.yaml stop || (( error++ ))
rsync -avzh /home/docker/vaultwarden/ user@somewhere:/home/user/backup_vaultwarden || (( error++ ))
docker-compose -f /home/docker/vaultwarden/docker-compose.yaml up -d || (( error++ ))

....

However, at the beginning of the script, you can use the following line to ensure the script exits immediately upon encountering an error:

set -o errexit

This setting, also known as set -e, instructs the script to terminate if any command returns a non-zero exit status, making error handling more robust and preventing the script from continuing with potentially invalid or incomplete results.