Can't backup on a ssh-mounted archive directory

Hi there ! Thanks for the amazing Yunohost, as always it makes everything so much simpler :slight_smile:

I have an issue with my particular installation: Yunohost is on a VPS with a relatively small disk, too small to make backups (a backup takes ~30 GiB, and I never have more than 20 GiB free). Let’s call that machine server

I could buy an additional disk but that’s extremely expensive for what I need to do, especially since I have another machine with enough storage: let’s call that machine storage

I did this:

$ sshfs storage:/path/to/archives /home/yunohost.backup/archives

to make archives on the storage machine. Unfortunately the backup doesn’t work, this is the stacktrace from the ui:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/moulinette/interfaces/api.py", line 453, in process
    ret = self.actionsmap.process(arguments, timeout=30, route=_route)
  File "/usr/lib/python3/dist-packages/moulinette/actionsmap.py", line 580, in process
    return func(**arguments)
  File "/usr/lib/python3/dist-packages/yunohost/log.py", line 410, in func_wrapper
    result = func(*args, **kwargs)
  File "/usr/lib/python3/dist-packages/yunohost/backup.py", line 2243, in backup_create
    _create_archive_dir()
  File "/usr/lib/python3/dist-packages/yunohost/backup.py", line 2627, in _create_archive_dir
    mkdir(ARCHIVES_PATH, mode=0o770, parents=True, gid="admins")
  File "/usr/lib/python3/dist-packages/moulinette/utils/filesystem.py", line 272, in mkdir
    os.mkdir(path, mode)
FileExistsError: [Errno 17] File exists: '/home/yunohost.backup/archives'

Looking at the code there is a check to see if the directory is correct:

os.path.isdir("/home/yunohost.backup/archives")

That test seems to return False in yunohost (which triggers the creation of the folder, which fails), but for some reason when run locally it returns True.

Has anyone managed to mount a directory for backups ? Am I missing anything ?

Replying myself because I found the solution: sshfs doesn’t allow other users to access the mount. The proper line to use is

$ sshfs -o allow_other storage:/path/to/archives /home/yunohost.backup/archives

Enjoy slow, but working backups !

3 Likes

Could this work with autofs, for using SBM or NFS instead of SSH on a local network ?

I guess it could work, so long as you don’t make the mistake I made and ensure the admin user can write there !

And how do you do that ? :smiley:

I don’t know how to mount using NFS, SMB and/or using autofs, so I can’t help you, you’ll have to see how those specifically work

:uk: I figured it out !

When using autofs, in the master file /etc/auto.master add the line :

/-     /etc/auto.nfs --ghost,--timeout=60

/- add something called direct map, which can be used to mount directly a folder buy using the dedicated file.
Then, in the /etc/auto.nfs file, add :

/path-to-your-folder/folder -fstype=nfs,rw ip:/path-of-your-share

And that should be working !

:fr: J’ai trouvé !

En utilisant autofs, dans le fichier master /etc/auto.master ajouter la ligne :

/-     /etc/auto.nfs --ghost,--timeout=60

/- ajoute une fonction appelée direct map, qui peut être utilisé pour monter directement un dossier par le fichier de configuration associé.
Puis, dans le fichier /etc/auto.nfs, ajoutez :

/path-to-your-folder/folder -fstype=nfs,rw ip:/path-of-your-share

Et ça devrait marcher !