lobaro / restic-backup-docker

A docker container to automate backups with restic
Apache License 2.0
331 stars 114 forks source link

sftp repo checking wasn't working #36

Closed tico24 closed 3 years ago

tico24 commented 4 years ago

The implemented repo check worked great for nfs or local filesystems, but seemed to fall over when I connected to my remote repo. I believe this fix should work for both.

Fair warning, there's every chance i've both over-engineered the solution and under-engineered the regex... this isn't my area of expertise.

niondir commented 4 years ago

Hey, thanks for the effort.

Can you clarify the issue that appears when checking against the remote SFTP repo. Do you have some logs or something. I wonder why restic is not able to check if a repository is initialized. You code implies that "restic snapshots" does not work at all for SFTP?

tico24 commented 4 years ago

Sorry, I don't have any logs. I fixed this a while back for our requirements.. just thought I'd best give it back. After your comment, I looked a bit harder and it turns out you might have fixed this already, and I have indeed over-engineered things!

Here was the code I had inherited from a previous version of your container entrypoint (from just before July):

if [ ! -f "$RESTIC_REPOSITORY/config" ]; then
    echo "Restic repository '${RESTIC_REPOSITORY}' does not exists. Running restic init."
    restic init | true

I think what happens is it never connects to the sftp repo, because the sftp command for restic is not standard. So this little if statement goes off and tries to run a restic init every time. But there's a chance the new code just works out of the box.

Apologies if I've wasted your time.

niondir commented 4 years ago

No problem, I just would love to hear if the current version does already work for you. Than we can safely close this PR.

tico24 commented 4 years ago

Leave it with me. My stuff is quite diverged from yours now, so it'll take some time. But I'll get back to you.