#1808 Issue closed: sshfs mount point not working.

Labels: support / question, fixed / solved / done

patlegu opened issue at 2018-05-16 21:57:

Relax-and-Recover (ReaR) Issue Template

Fill in the following items before submitting a new issue
(quick response is not guaranteed with free support):

  • ReaR version ("/usr/sbin/rear -V"): 2.3
  • OS version ("cat /etc/rear/os.conf" or "lsb_release -a" or "cat /etc/os-release"): DEBIAN 9.2
  • ReaR configuration files ("cat /etc/rear/site.conf" or "cat /etc/rear/local.conf"):
    OUTPUT_URL="sshfs://rear-uxdc01@ /home/rear-uxdc01/ISOs port=22222"
  • System architecture (x86 compatible or POWER and/or what kind of virtual machine):
  • Are you using BIOS or UEFI or another way to boot?
  • Brief description of the issue:
    sshfs mount not working properly. The cmd is working fine when used on cmd line but it's falling in error when used configured in /etc/rear/local.conf.
++ local defaultoptions=rw,noatime
++ local options=port=22222
++ local mount_cmd
++ case $(url_scheme $url) in
+++ url_scheme sshfs://rear-uxdc01@
+++ local url=sshfs://rear-uxdc01@
+++ local scheme=sshfs
+++ echo sshfs
+++ grep -q :
+++ echo sshfs
+++ url_host sshfs://rear-uxdc01@
+++ local url=sshfs://rear-uxdc01@
+++ local url_without_scheme=rear-uxdc01@
+++ local authority_part=rear-uxdc01@
+++ echo rear-uxdc01@
++ local authority=rear-uxdc01@
++ test rear-uxdc01@
+++ url_path sshfs://rear-uxdc01@
+++ local url=sshfs://rear-uxdc01@
+++ local url_without_scheme=rear-uxdc01@
+++ echo /home/rear-uxdc01/ISOs
++ local path=/home/rear-uxdc01/ISOs
++ test /home/rear-uxdc01/ISOs
++ lsmod
++ grep -q '^fuse'
++ mount_cmd='sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222'
++ Log 'Mounting with '\''sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222'\'''
+++ date '+%Y-%m-%d %H:%M:%S.%N '
++ local 'timestamp=2018-05-16 23:35:50.195815668 '
++ test 1 -gt 0
++ echo '2018-05-16 23:35:50.195815668 Mounting with '\''sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222'\'''
2018-05-16 23:35:50.195815668 Mounting with 'sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222'
++ eval sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222
+++ sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222
++ StopIfError 'Mount command '\''sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222'\'' failed.'
++ ((  0 != 0  ))
++ AddExitTask 'umount -f -v '\''/home/rear-uxdc01/ISOs'\'' >&2'
++ EXIT_TASKS=("$*" "${EXIT_TASKS[@]}")
++ Debug 'Added '\''umount -f -v '\''/home/rear-uxdc01/ISOs'\'' >&2'\'' as an exit task'
++ test 1
++ Log 'Added '\''umount -f -v '\''/home/rear-uxdc01/ISOs'\'' >&2'\'' as an exit task'
+++ date '+%Y-%m-%d %H:%M:%S.%N '
++ local 'timestamp=2018-05-16 23:35:50.690206299 '
++ test 1 -gt 0
++ echo '2018-05-16 23:35:50.690206299 Added '\''umount -f -v '\''/home/rear-uxdc01/ISOs'\'' >&2'\'' as an exit task'
2018-05-16 23:35:50.690206299 Added 'umount -f -v '/home/rear-uxdc01/ISOs' >&2' as an exit task
++ return 0

sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222 is working fine.

  • Work-around, if any:

patlegu commented at 2018-05-17 11:22:

The mount_cmd is working fine, it appears on 'df -k' while the rear mkbackup run but it's dismounted as the function StopIfError seem to see it failed. What's very strange is that the return code is 0 as we can see in the test [ 0 !=0 ]

jsmeix commented at 2018-05-17 14:02:

I am not a sshfs user but I think

OUTPUT_URL="sshfs://rear-uxdc01@ /home/rear-uxdc01/ISOs port=12222"

cannot work because man rear reads

    To backup to a remote server via sshfs (SSH protocol), use

and OUTPUT_URL has same syntax as BACKUP_URL
because man rear also reads

If you do not specify OUTPUT_URL variable then by default
it will be aligned to what was defined by variable BACKUP_URL


patlegu commented at 2018-05-17 16:43:

I'm not trying to backup true sshfs, I'm doing this true BORG. I'm just trying to save the iso on a sshfs directory instead of getting it locally. So it's the good variable, OUTPUT_URL

If I use the MOUNT_CMD generated and launch it manually, no problem. The remote directory is mounted locally on /home/rear-uxdc01/ISOs
After that if, I put in the local.conf
which is the mount point of the sshfs
The rear mkbackup save the iso file as expected in the mount point /home/rear-uxdc01/ISOs
So you we can expect to let it as this, but the problem is that my backup server will have many others connected to it, and you can easily imagine the impact to let all theses sshfs opened.

By using the OUTPUT_URL, sshfs is mounted before the backup and dismounted at the end.

gozora commented at 2018-05-17 17:04:

@patlegu can you please provide your local.conf you are using ?



patlegu commented at 2018-05-17 17:45:

OUTPUT_URL="sshfs://rear-uxdc01@ /home/rear-uxdc01/ISOs port=22222"


COPY_AS_IS_BORG=( /root/.config/borg/keys/,/usr/sbin/borg-linux64-standalone,/usr/sbin/borg )
export  BORG_PASSPHRASE='some good alphanumeric key'
export BORG_REPO='/home/rear-uxdc01/backup'

gozora commented at 2018-05-18 05:33:

@patlegu I'll check this later today and let you know ...


gozora commented at 2018-05-18 05:41:

@patlegu In you initial https://github.com/rear/rear/issues/1808#issue-323802357 you are mentioning:

The cmd is working fine when used on cmd line but it's falling in error when used configured in /etc/rear/local.conf.

What exactly is the error you are getting ?


jsmeix commented at 2018-05-18 07:01:

in https://github.com/rear/rear/issues/1808#issuecomment-389951364
there is still that strange OUTPUT_URL="first_word second_word third_word"
which does not look right as far as I can guess as a non-sshfs user,
cf. https://github.com/rear/rear/issues/1808#issuecomment-389877411

gozora commented at 2018-05-18 07:12:

Hello @jsmeix,

INDEED! Thanks!

@patlegu You can't use such format for OUTPUT_URL.
You need ReaR to choose the mount point.
And if you need to specify non-default port for SSH operations, I'd recommend to use ~/.ssh/config something like:

     Port 22222

patlegu commented at 2018-05-18 07:27:

@jsmeix,@gozora: You're right, this syntax is needed by Rear, not sshfs. These three parameters are analyzed in the 'global-functions.sh' functions and used by mount_url for sshfs (line 399):
'### Mount URL $1 at mountpoint $2[, with options $3]'
For sshfs, resulting in this command : mount_cmd="sshfs $authority:$path $mountpoint -o $options"
and that's what I get (line 434):
mount_cmd="sshfs rear-uxdc01@ /home/rear-uxdc01/ISOs -o port=22222"
I think I've finded where is the problem and I'm testing this today and let you know.


jsmeix commented at 2018-05-18 07:37:

see also default.conf e.g. the current one at
that reads in particular

# In case of doubt inspect the scripts how exactly a particular variable works.


# Output/backup locations

# The URL defines the remote share as :/// like these examples:
# nfs://host.domain/path/path/path
# cifs://server.domain/share
# usb:///dev/sdb1
# Additional options to the mount command are given using *_OPTIONS
# Alternatively, you can provide your own mount/unmount commands, in that case
# Relax-and-Recover will append its mountpoint to the command.
# Specify the location of the output:
# When OUTPUT_URL is not specified it inherits the BACKUP_URL value.

and the main script how exactly that works is
therein the mount_url() function
together with the other URL related functions therein.

I never used things like OUTPUT_MOUNTCMD but as far as I see in
OUTPUT_MOUNTCMD cannnot be a string of words but must be a single command
and all the options to the mount command must be in OUTPUT_OPTIONS.

patlegu commented at 2018-05-18 09:59:

@jsmeix : You're right, but I don't say I use this OUTPUT_MOUNTCMD in configuration file. I just say that mount_cmd appear in the log file, and I try to copy and paste it in a shell and it work. That's just this, I've not been as clear as I should have been, sorry.
And as you mentioned, the only option I've used in local.conf is:
OUTPUT_URL="sshfs://rear-uxdc01@ /home/rear-uxdc01/ISOs port=22222"

patlegu commented at 2018-05-21 13:17:

I've found where is the problem. The remote directory is mounted under a path and the iso file is copied to another one in the temporary working path. To work, the output_path function just need to be modified.

    # type file needs a local path (must be mounted by user)
    # type sshfs need a local path too but is mounted and unmounted automatically before and after the files copy.
    # To work properly, the OUPUT_URL must be set in the /etc/rear/local.conf file like this :
    # OUTPUT_URL="sshfs://<remote user>@<remote host><remote path> <local mount point> <sshfs option>"
    # Be carefull to not include the ":" between <remote host><remote path> as it's done automatically.
    # This exemple OUTPUT_URL="sshfs://rear-user@11.222.333.444/home/rear-user/ISOs /home/rear-user/ISOs
    # NOTE that sshfs options can be cumulated like this : port=2222,idmap=user

Hope this help.

[Export of Github issue for rear/rear.]