#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@88.182.85.28/home/rear-uxdc01/ISOs /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.
/mount_cmd
...skipping
++ local defaultoptions=rw,noatime
++ local options=port=22222
++ local mount_cmd
++ case $(url_scheme $url) in
+++ url_scheme sshfs://rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ local url=sshfs://rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ local scheme=sshfs
+++ echo sshfs
+++ grep -q :
+++ echo sshfs
+++ url_host sshfs://rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ local url=sshfs://rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ local url_without_scheme=rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ local authority_part=rear-uxdc01@88.182.85.28
+++ echo rear-uxdc01@88.182.85.28
++ local authority=rear-uxdc01@88.182.85.28
++ test rear-uxdc01@88.182.85.28
+++ url_path sshfs://rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ local url=sshfs://rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ local url_without_scheme=rear-uxdc01@88.182.85.28/home/rear-uxdc01/ISOs
+++ 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@88.182.85.28:/home/rear-uxdc01/ISOs /home/rear-uxdc01/ISOs -o port=22222'
++ Log 'Mounting with '\''sshfs rear-uxdc01@88.182.85.28:/home/rear-uxdc01/ISOs /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@88.182.85.28:/home/rear-uxdc01/ISOs /home/rear-uxdc01/ISOs -o port=22222'\'''
2018-05-16 23:35:50.195815668 Mounting with 'sshfs rear-uxdc01@88.182.85.28:/home/rear-uxdc01/ISOs /home/rear-uxdc01/ISOs -o port=22222'
++ eval sshfs rear-uxdc01@88.182.85.28:/home/rear-uxdc01/ISOs /home/rear-uxdc01/ISOs -o port=22222
+++ sshfs rear-uxdc01@88.182.85.28:/home/rear-uxdc01/ISOs /home/rear-uxdc01/ISOs -o port=22222
++ StopIfError 'Mount command '\''sshfs rear-uxdc01@88.182.85.28:/home/rear-uxdc01/ISOs /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

The CMD LINE :
sshfs rear-uxdc01@88.182.85.28:/home/rear-uxdc01/ISOs /home/rear-uxdc01/ISOs -o port=22222 is working fine.

  • Work-around, if any:
    none

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@51.15.151.255/home/rear-uxdc01/ISOs /home/rear-uxdc01/ISOs port=12222"

cannot work because man rear reads

BACKUP_URL=sshfs://
    To backup to a remote server via sshfs (SSH protocol), use
    BACKUP_URL=sshfs://user@remote-system.name.org/home/user/backup-dir/

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

cf.
https://github.com/rear/rear/blob/master/doc/rear.8.adoc

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
I don't use BACKUP_URL as BACKUP=BORG with BORGBACKUP_HOST and BORGBACKUP_PORT

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
OUTPUT_URL="file:////home/rear-uxdc01/ISOs"
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 ?

Thanks

V.

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

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

BACKUP=BORG
BORGBACKUP_HOST="88.182.85.28"
BORGBACKUP_PORT="22222"
BORGBACKUP_USERNAME="rear-uxdc01"
BORGBACKUP_REPO="/home/rear-uxdc01/backup"
BORGBACKUP_REMOTE_PATH="/usr/sbin/borg"
BORGBACKUP_ARCHIVE_CACHE="/tmp/borg_archive"
BORGBACKUP_ARCHIVE_PREFIX="rearuxdc01"

BORGBACKUP_ENC_TYPE="repokey"
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'
export BORG_RELOCATED_REPO_ACCESS_IS_OK="yes"
export BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK="yes"

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

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

V.

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 ?

V.

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

@gozora
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:

Host 88.182.85.28
     Port 22222

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

Hello.
@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@88.182.85.28:/home/rear-uxdc01/ISOs /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.

Pat.

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

@patlegu
see also default.conf e.g. the current one at
https://github.com/rear/rear/blob/master/usr/share/rear/conf/default.conf
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.
OUTPUT_URL=
OUTPUT_OPTIONS=
OUTPUT_MOUNTCMD=
OUTPUT_UMOUNTCMD=
OUTPUT_PREFIX="$HOSTNAME"

and the main script how exactly that works is
usr/share/rear/lib/global-functions.sh
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
usr/share/rear/output/default/100_mount_output_path.sh
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@88.182.85.28/home/rear-uxdc01/ISOs /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.

(file|sshfs)
    # 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.
@+
Pat


[Export of Github issue for rear/rear.]