backups: Add options to keep sshfs shares responsive

Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Guillermo Lopez Alejos 2022-04-15 13:19:35 +02:00 committed by Sunil Mohan Adapa
parent d7c9c89257
commit d7a1ea03a3
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2

View File

@ -55,10 +55,20 @@ def subcommand_mount(arguments):
kwargs = {}
# the shell would expand ~/ to the local home directory
remote_path = remote_path.replace('~/', '').replace('~', '')
# 'reconnect', 'ServerAliveInternal' and 'ServerAliveCountMax' allow the
# client (FreedomBox) to keep control of the SSH connection even when the
# SSH server misbehaves. Without these options, other commands such as
# '/usr/share/plinth/actions/storage usage-info', 'df',
# '/usr/share/plinth/actions/sshfs is-mounted', or 'mountpoint' might block
# indefinitely (even when manually invoked from the command line). This
# situation has some lateral effects, causing major system instability in
# the course of ~11 days, and leaving the system in such state that the
# only solution is a reboot.
cmd = [
'sshfs', remote_path, arguments.mountpoint, '-o',
f'UserKnownHostsFile={arguments.user_known_hosts_file}', '-o',
'StrictHostKeyChecking=yes'
'StrictHostKeyChecking=yes', '-o', 'reconnect', '-o',
'ServerAliveInterval=15', '-o', 'ServerAliveCountMax=3'
]
if arguments.ssh_keyfile:
cmd += ['-o', 'IdentityFile=' + arguments.ssh_keyfile]