YunoHost-Apps / borgserver_ynh

Borg server package for YunoHost
https://www.borgbackup.org/
GNU Affero General Public License v3.0
9 stars 5 forks source link

"Backup missing" notifications when backup repo is not ~/backup #44

Open eauchat opened 3 years ago

eauchat commented 3 years ago

Describe the bug

Twice a day (at 9AM and 8PM) the admin email is receiving the following mails:

Subject: Cron <root@magari> : Monitor borgserv_sshuser backup ; ALERT_DELAY="$(yunohost app setting borgserver alert_delay)"; [[ $(find /home/borgserv_sshuser/backup -follow -mtime -${ALERT_DELAY} -ls | wc -l) > 0 ]] || ( echo "No file has been backuped in /home/borgserv_sshuser since ${ALERT_DELAY} days" | mail -s "[YNH] Backup missing : borgserv_sshuser" $(yunohost app setting borgserver alert_mails))
Content: find: ‘/home/borgserv_sshuser/backup’: No such file or directory
Subject: [YNH] Backup missing : borgserv_sshuser 
Content: No file has been backuped in /home/borgserv_sshuser since 1 days

Context

Expected behavior

Not receiving the error mails. Being able to explain to borgserver the paths to the repos, so that it can check that backups are being done properly.

alexAubin commented 3 years ago

Can you elaborate what you did for borg to use a custom location ?

eauchat commented 3 years ago

Hmm I believe now borg_ynh allows to use any custom location, so in borg_ynh I'm having as repository: ssh://ssh_user@targetdomain.tld/~/someCustomRepo. I don't remember having to do much on borgserver_ynh side, just updating .ssh/authorized_keys with the appropriate repository path. I think that's how far I went in "customizing". Also, I had to customize the repository because I'm having two different repositories receiving backups on borgserver_ynh side (wanted to keep them separated).

eauchat commented 3 years ago

To be crystal clear, I have two servers to backup (A and B), each has borg installed, their repositories are:

In the backup server, I have borgserver_ynh installed, and /home/ssh_user/.ssh/authorized_keys looks like this:

ssh-ed25519 XXXXXXXXX personal@computer
command="borg serve --storage-quota XXG --restrict-to-repository /home/ssh_user/serverA",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc ssh-ed25519 XXXXXXXXX root@serverA
command="borg serve --storage-quota XXG --restrict-to-repository /home/ssh_user/serverB",no-pty,no-agent-forwarding,no-port-forwarding,no-X11-forwarding,no-user-rc ssh-ed25519 XXXXXXXXX root@serverB
alexAubin commented 3 years ago

Eh yeah I guess we just gotta be clever in the cron job generation here https://github.com/YunoHost-Apps/borgserver_ynh/blob/testing/conf/monitor-backup#L2 and include the full path instead of /home/__SSH_USER__

eauchat commented 3 years ago

Proposed a patch to resolve this: #46