YunoHost-Apps/borg_ynh

repository already exists at ...

benneti opened this issue · 10 comments

Since (probably the last update) i get in the status mail a lot of lines like
A repository already exists at ssh://yunohost-backups@target-host/~/backup.
But borg list yunohost-backups@target-host:backup::auto_borg-2021-04-23_06:47 contains the backup (before the name did not have the leading "".
The corresponding journal log (sudo journalctl -u borg.service) reads

-- Logs begin at Fri 2021-04-23 01:23:26 CEST, end at Fri 2021-04-23 09:14:50 CEST. --
Apr 23 06:44:25 myyunohostdomain sudo[18021]: pam_unix(sudo:session): session closed for user root
Apr 23 06:44:26 myyunohostdomain sudo[17334]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost app setting borg apps
Apr 23 06:44:26 myyunohostdomain sudo[17334]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 06:46:31 myyunohostdomain sudo[17334]: pam_unix(sudo:session): session closed for user root
Apr 23 06:46:31 myyunohostdomain sudo[18323]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/bin/ls /etc/yunohost/apps/
Apr 23 06:46:31 myyunohostdomain sudo[18323]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 06:46:31 myyunohostdomain sudo[18323]: pam_unix(sudo:session): session closed for user root
Apr 23 06:46:31 myyunohostdomain sudo[18330]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/borg/scripts/backup
Apr 23 06:46:31 myyunohostdomain sudo[18330]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 06:46:32 myyunohostdomain sudo[18330]: pam_unix(sudo:session): session closed for user root
Apr 23 06:46:32 myyunohostdomain sudo[18335]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_borg --method borg_app --apps borg
Apr 23 06:46:32 myyunohostdomain sudo[18335]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 06:59:57 myyunohostdomain sudo[18335]: pam_unix(sudo:session): session closed for user root
Apr 23 06:59:57 myyunohostdomain sudo[20752]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/gitea/scripts/backup
Apr 23 06:59:57 myyunohostdomain sudo[20752]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 06:59:57 myyunohostdomain sudo[20752]: pam_unix(sudo:session): session closed for user root
Apr 23 06:59:57 myyunohostdomain sudo[20755]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_gitea --method borg_app --apps gitea
Apr 23 06:59:57 myyunohostdomain sudo[20755]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:11:07 myyunohostdomain sudo[20755]: pam_unix(sudo:session): session closed for user root
Apr 23 07:11:07 myyunohostdomain sudo[23184]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/mautrix_telegram/scripts/backup
Apr 23 07:11:07 myyunohostdomain sudo[23184]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:11:07 myyunohostdomain sudo[23184]: pam_unix(sudo:session): session closed for user root
Apr 23 07:11:08 myyunohostdomain sudo[23188]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_mautrix_telegram --method borg_app --apps mautrix_telegram
Apr 23 07:11:08 myyunohostdomain sudo[23188]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:13:42 myyunohostdomain sudo[24279]:     root : TTY=unknown ; PWD=/home/yunohost.backup/tmp/auto_mautrix_telegram/apps/mautrix_telegram/backup ; USER=postgres ; COMMAND=/bin/bash -c pg_dump mautrix_telegram
Apr 23 07:13:42 myyunohostdomain sudo[24279]: pam_unix(sudo:session): session opened for user postgres by (uid=0)
Apr 23 07:13:44 myyunohostdomain sudo[24279]: pam_unix(sudo:session): session closed for user postgres
Apr 23 07:17:51 myyunohostdomain sudo[23188]: pam_unix(sudo:session): session closed for user root
Apr 23 07:17:51 myyunohostdomain sudo[24955]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/monitorix/scripts/backup
Apr 23 07:17:51 myyunohostdomain sudo[24955]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:17:51 myyunohostdomain sudo[24955]: pam_unix(sudo:session): session closed for user root
Apr 23 07:17:52 myyunohostdomain sudo[24957]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_monitorix --method borg_app --apps monitorix
Apr 23 07:17:52 myyunohostdomain sudo[24957]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:22:58 myyunohostdomain sudo[24957]: pam_unix(sudo:session): session closed for user root
Apr 23 07:22:58 myyunohostdomain sudo[26346]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/my_webapp/scripts/backup
Apr 23 07:22:58 myyunohostdomain sudo[26346]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:22:58 myyunohostdomain sudo[26346]: pam_unix(sudo:session): session closed for user root
Apr 23 07:22:58 myyunohostdomain sudo[26349]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_my_webapp --method borg_app --apps my_webapp
Apr 23 07:22:58 myyunohostdomain sudo[26349]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:27:09 myyunohostdomain sudo[26349]: pam_unix(sudo:session): session closed for user root
Apr 23 07:27:09 myyunohostdomain sudo[27772]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/nextcloud/scripts/backup
Apr 23 07:27:09 myyunohostdomain sudo[27772]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:27:09 myyunohostdomain sudo[27772]: pam_unix(sudo:session): session closed for user root
Apr 23 07:27:09 myyunohostdomain sudo[27779]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_nextcloud --method borg_app --apps nextcloud
Apr 23 07:27:09 myyunohostdomain sudo[27779]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:59:30 myyunohostdomain sudo[27779]: pam_unix(sudo:session): session closed for user root
Apr 23 07:59:30 myyunohostdomain sudo[580]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/synapse/scripts/backup
Apr 23 07:59:30 myyunohostdomain sudo[580]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:59:30 myyunohostdomain sudo[580]: pam_unix(sudo:session): session closed for user root
Apr 23 07:59:31 myyunohostdomain sudo[583]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_synapse --method borg_app --apps synapse
Apr 23 07:59:31 myyunohostdomain sudo[583]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 07:59:49 myyunohostdomain sudo[1121]:     root : TTY=unknown ; PWD=/home/yunohost.backup/tmp/auto_synapse/apps/synapse/backup ; USER=postgres ; COMMAND=/bin/bash -c pg_dump matrix_synapse
Apr 23 07:59:49 myyunohostdomain sudo[1121]: pam_unix(sudo:session): session opened for user postgres by (uid=0)
Apr 23 08:01:44 myyunohostdomain sudo[1121]: pam_unix(sudo:session): session closed for user postgres
Apr 23 08:21:33 myyunohostdomain sudo[583]: pam_unix(sudo:session): session closed for user root
Apr 23 08:21:34 myyunohostdomain sudo[5894]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/ttrss/scripts/backup
Apr 23 08:21:34 myyunohostdomain sudo[5894]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 08:21:34 myyunohostdomain sudo[5894]: pam_unix(sudo:session): session closed for user root
Apr 23 08:21:34 myyunohostdomain sudo[5897]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_ttrss --method borg_app --apps ttrss
Apr 23 08:21:34 myyunohostdomain sudo[5897]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 08:28:15 myyunohostdomain sudo[5897]: pam_unix(sudo:session): session closed for user root
Apr 23 08:28:16 myyunohostdomain sudo[7410]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/unattended_upgrades/scripts/backup
Apr 23 08:28:16 myyunohostdomain sudo[7410]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 08:28:16 myyunohostdomain sudo[7410]: pam_unix(sudo:session): session closed for user root
Apr 23 08:28:16 myyunohostdomain sudo[7412]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_unattended_upgrades --method borg_app --apps unattended_upgrades
Apr 23 08:28:16 myyunohostdomain sudo[7412]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 08:35:36 myyunohostdomain sudo[7412]: pam_unix(sudo:session): session closed for user root
Apr 23 08:35:36 myyunohostdomain sudo[9009]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/test ! -f /etc/yunohost/apps/wallabag2/scripts/backup
Apr 23 08:35:36 myyunohostdomain sudo[9009]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 08:35:36 myyunohostdomain sudo[9009]: pam_unix(sudo:session): session closed for user root
Apr 23 08:35:36 myyunohostdomain sudo[9012]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost backup create -n auto_wallabag2 --method borg_app --apps wallabag2
Apr 23 08:35:36 myyunohostdomain sudo[9012]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 08:43:34 myyunohostdomain sudo[9012]: pam_unix(sudo:session): session closed for user root
Apr 23 08:43:35 myyunohostdomain sudo[11024]:     root : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/bin/yunohost app setting borg repository
Apr 23 08:43:35 myyunohostdomain sudo[11024]: pam_unix(sudo:session): session opened for user root by (uid=0)
Apr 23 08:43:41 myyunohostdomain sudo[11024]: pam_unix(sudo:session): session closed for user root
Apr 23 08:43:42 myyunohostdomain sudo[15379]: pam_unix(sudo:session): session closed for user root
Apr 23 08:43:42 myyunohostdomain systemd[1]: borg.service: Main process exited, code=exited, status=1/FAILURE
Apr 23 08:43:42 myyunohostdomain systemd[1]: borg.service: Failed with result 'exit-code'.
Apr 23 08:43:42 myyunohostdomain systemd[1]: Failed to start Run backup borg.

never mind the next backup worked again

Reopening, because it seems like every second backup is failing according to the logs

Same issue for me : I removed and reinstalled borg backup to be able to upgrade (local backup, I couldn't upgrade because of backup pre-upgrade failing), and now I get this same error :

Échec de la méthode de sauvegarde personnalisée à l’étape 'backup'
A repository already exists at /media/DD2T/Sauvegardes/borg.

It's true, the repository already exists, I just want borg to increment this existing backup (I gave the same folder and same passphrase during installation).

Edit : backup log : https://plaf.fr/zerobin/?07b0253cf639c70f#EqNQ7k1ytGLLnbwJxK2oRHpsCQAPW1p6NLpXosqJPUT4

I think I fixed it by removing the lock of the archive borg break-lock yunohost-backups@remote:backup . @tomdereub you could try whether this helps in your case, too.
( I cannot access your logs)

EDIT: Fails again

@benneti : thanks, it seems to be working for me (two successful backups for now), even after upgrade to yunohost 4.2.

@tomdereub is it working consistently for you, for me it starts failing again after some days

It's working well for me, I've just a problem with peertube's backup failing, but I didn't take time to investigate this yet.

Actually, I'm getting this error quite often, on 2 different servers. Every time, a borg break-lock resolves the issue for the few next backups, but if a backup is failing for example I have to do it again.
And a strange thing : peertube's backup is often failing, with this same error "A repository already exists at /truc/repoborg". What is strange is that peertube's backup comes after and before working backups of other apps.

Extract from the logs sent by mail :

Collecte des fichiers devant être sauvegardés pour opensondage...
Loading installation settings...
Declaring files to be backed up...
Backup script completed for opensondage. (YunoHost will then actually copy those files to the archive).
Création d’une archive de sauvegarde à partir des fichiers collectés...
L'archive contiendra environ 12.9MiB de données.
Sauvegarde terminée
name: auto_opensondage
results: 
  apps: 
    opensondage: Success
  system: 
size: 13510951
Collecte des fichiers devant être sauvegardés pour peertube...
Loading installation settings...
Declaring files to be backed up...
Backing up data directory...
Backing up the PostgreSQL database...
Backup script completed for peertube. (YunoHost will then actually copy those files to the archive).
Création d’une archive de sauvegarde à partir des fichiers collectés...
L'archive contiendra environ 27.7GiB de données.
L’opération 'Créer une archive de sauvegarde' a échoué ! Pour obtenir de l’aide, merci de partager le journal de l’opération en utilisant la commande 'yunohost log share 20210609-025553-backup_create'
Collecte des fichiers devant être sauvegardés pour rainloop...
Loading installation settings...
Declaring files to be backed up...
Backup script completed for rainloop. (YunoHost will then actually copy those files to the archive).
Création d’une archive de sauvegarde à partir des fichiers collectés...
L'archive contiendra environ 122.7MiB de données.
Sauvegarde terminée
name: auto_rainloop
results: 
  apps: 
    rainloop: Success
  system: 
size: 128636134
Collecte des fichiers devant être sauvegardés pour redirect...
Création d’une archive de sauvegarde à partir des fichiers collectés...
L'archive contiendra environ 49.9KiB de données.
Sauvegarde terminée

And peertube's backup log contains "A repository already exists at /truc/repoborg".

Edit : actually peertube's backup seems to be successful, I can find all files in the borg repository. So I don't understand why I get this line in the mail "The backup miserably failed to backup peertube application.".

I think since one of the last updates this now happens on every backup and additionally complains about a missing translation:

A repository already exists at ssh://yunohost-backups@remote/~/backup.
``
I guess the first message with A repository is alredy is expected and can be suppresed by piping standard out to /dev/null in https://github.com/YunoHost-Apps/borg_ynh/blob/36fc746f08a6e302b80c0c531eea1512adda8a77/conf/backup_method#L37

Actually it seems that "A repository already exists at /truc/repoborg" is just a warning and isn't the cause of failed backup.
On my server, peertube's backup are always marked as failed, but the cause is :

2023-05-23 08:31:35,053: DEBUG - [2023-05-23_07:12:25] apps/peertube/backup/home/yunohost.app/peertube/storage/thumbnails/55ceb81d-c2b3-4f97-940d-15bd31a3322c.jpg: stat: [Errno 2] No such file or directory: 'apps/peertube/backup/home/yunohost.app/peertube/storage/thumbnails/55ceb81d-c2b3-4f97-940d-15bd31a3322c.jpg'
2023-05-23 08:31:35,075: DEBUG - [2023-05-23_07:12:25] apps/peertube/backup/home/yunohost.app/peertube/storage/thumbnails/34a90f29-3b02-440f-aa05-41b5d68a0b6e.jpg: stat: [Errno 2] No such file or directory: 'apps/peertube/backup/home/yunohost.app/peertube/storage/thumbnails/34a90f29-3b02-440f-aa05-41b5d68a0b6e.jpg'
2023-05-23 08:31:35,076: DEBUG - [2023-05-23_07:12:25] apps/peertube/backup/home/yunohost.app/peertube/storage/thumbnails/4780c37f-0d56-48a7-8151-5bc482e34774.jpg: stat: [Errno 2] No such file or directory: 'apps/peertube/backup/home/yunohost.app/peertube/storage/thumbnails/4780c37f-0d56-48a7-8151-5bc482e34774.jpg'

It seems that there are some files changing during the backup. Actually the backup works (all files are present in backup, restore is working), but it's marked as failed by borg's script, wich is annoying...