Backup from Ubuntu to FreeBSD fails

I’m attempting to create a backup with restic from a Ubuntu for to a FreeBSD over SFTP.
Unfortunately, I don’t get a working backup and have a hard time to understand why. Maybe you have some hints for me?
Here is what I did and experienced so far:

Creating a backup - seems to work:

restic -r sftp:user@host:resticrepo backup /home/user* 

enter password for repository: 
password is correct
scan [/home/user]
scanned 23278 directories, 196537 files in 1:01
warning for /home/user/userapp.log: expected 2123412196 bytes, saved 2123458093 bytes
[1:08:32] 100.00%  253.416 GiB / 253.416 GiB  219815 / 219815 items  0 errors  ETA 0:00 
duration: 1:08:32
snapshot 6e5c635f saved

Check backup - fails with lock

restic -r sftp:user@host:resticrepo check

enter password for repository: 
password is correct
create exclusive lock for repository
Fatal: unable to create lock in backend: repository is already locked by PID 14294 on XXX by root (UID 0, GID 0)
lock was created at 2018-03-25 21:33:27 (25h2m14.852978177s ago)
storage ID 18d2949f

Check back up with --no-lock -shows various errors
restic -r sftp:user@host:resticrepo check --no-lock

enter password for repository: 
password is correct
load indexes
check all packs
pack f0356d45402fdd3b2f87c1313d97502007f11bc2f12d0d6d2e151e022b4ba11e: not referenced in any index
pack c758e6495372574a6fb26e2c08b32cfb9f2d6445e2cbe1ad901a9747d43e753e: not referenced in any index
pack acf070745324ba7b5f0b39210c5ac7eff7e49ea1b090ee1d1e218e52f9356fd9: not referenced in any index
pack 925a5016f6ef1a861a807747ce4d03fb91dffa3e0f1166a35005f7f1bd86c983: not referenced in any index
check snapshots, trees and blobs
Fatal: repository contains errors

I also tried to re-run the backup and get the snapshots of those attempt listed by
restic -r sftp:user@host:resticrepo snapshots :

enter password for repository: 
password is correct

ID        Date                 Host                   Tags        Directory
53b96cb4  2018-03-25 23:38:24  XXX                                 ...

6e5c635f  2018-03-26 15:28:20  XXX                                 ...

dd99a3a8  2018-03-28 14:46:36  XXX                                 ...
3 snapshots

Any hints what I can do or look at to make this work?

thank a lot

This looks to me as if you had 2 concurrent actions running on 1 repository which restic doesn’t handle very well but should do no harm.

Make sure that there are no clients accessing the repository then remove the lock (restic unlock) and run restic rebuild-index.

I agree with @764287, it looks like there was an backup which is either still running, or has aborted without removing the lock file. Can you check it’s really not running any more? Then follow @764287’s recommendation: restic unlock && restic rebuild-index.

What restic tells you here is that there’s data in the repo that is not yet present in the index. During backup, restic first uploads data files, and only afterwards (and at regular intervals during the backup) uploads an index file which references it. The error restic check prints should really be just a warning, I need to find time to rework the user interface here.

thanks a lot for the prompt reply!
Unfortunately, just a unlock & rebuild did not make the error message go away. Also not running it multiple times. But as newer backups seemed to be running fine, I gave it a try to remove the oldest snapshot - and that made it, no errors anymore :slight_smile:
Thanks for your help and for working on restic !