2

I have mounted a webdav folder using webdav as described here . For mounting this directory I use the following command:

sudo mount -t davfs -o uid=bruni,gid=users https://serveraddress /home/bruni/mountpoint

However, when trying to sync this folder using freefilesync I get the following error:

Cannot set directory lock for "/path/to/mountpoint".

Cannot write file "/path/to/mountpoint/sync.ffs_lock".

Error Code 13:Permission denied (open)

Please note that this problem is not related to the TLS encryption as it also arises when I do not use https (when I am at office).

Also note that I am able to create files in the mounted directory from the terminal or even nautilus. So my question is, why can't freefilesync and how could I solve the particular problem?

I use Ubuntu 16.04 and Freefilesync 8.2, but I can imagine that this is redundant information.

UPDATE 5/7/2016: Here are the permissions on the top level mount point:

ls -l
drwxr-xr-x 16 bruni users    488 Jun 14 14:19 Infolog

And here on the directory the lock file should be made

ls -l
drwxr-xr-x 16 bruni users 0 May  31 22:07 id54843

id54843 is a directory, deep under Infolog.

Freefilesync is running as bruni

bruni   8448  1.9  0.2 753820 46684 ?        Sl   11:24   1:05 /home/bruni/Downloads/Software/Linux/FreeFileSync/FreeFileSync

I wan't to sync 2way.

Bruni
  • 10,542
  • Can you show what access permission you have on directory /path/to/mountpoint and which user runs FreeFileSync in that context. ? – Cbhihe Jul 05 '16 at 08:04
  • @Cbhihe Added info on the permissions. Don't know how to do the latter. – Bruni Jul 05 '16 at 08:31
  • In terminal: $ <yr FreeFileSync cmd> & ; sleep 1; sudo ps -aux | grep FreeFileSync | grep -v grep BTW are you trying to "FreeFilesSync" from OR to /home/Bruni/Infolog or some other directoy deeper in that tree ? – Cbhihe Jul 05 '16 at 09:20

1 Answers1

1

+1 : Interesting question.

Freefilesync may require sudo privileges to backup certain files in the volumes it parses. To my knowledge it is not good to preserve rwx oder ownership of files.

If you execute it from cli, the proper syntax is:

$ sudo -i -g bruni /usr/bin/FreeFileSync "${HOME}"/.FreeFileSync/backup-jobref.ffs_batch 2> "${HOME}"/.FreeFileSync/backup-jobref.ffs_log

The above suppose that within FreeFileSync's GUI you have previously defined a batch job and saved it as: "${HOME}"/.FreeFileSync/backup-jobref.ffs_batch.

If however you intend to run the job from an automated script, make sure that the variables you use explicitly or implicitly are known in yr execution environment (cron, udev, ...):

  • $HOME
  • $DISPLAY
    Don't leave it undefined in your script, include for instance:
    # define local default display and pass it on to any child process
    DISPLAY=:0 ; export DISPLAY

DISPLAY=:0 ; export DISPLAY may not suit your use case if you are doing remote admin on a distant volume while executing a remote instance of FreeFileSync. In that case you'll have to define DISPLAY appropriately.

If you don't want to have to enter your sudo password every time yr backup job runs, or if you want it to run unattended, then go to: /etc/sudoers.d/ and sudo-edit the file 10_user or whatever name you choose, with:

%admin yr_host = NOPASSWD: /usr/bin/FreeFileSync

where admin is any user group that contains you and those you authorize to run FreeFileSync with root privileges. Visit man sudoers to learn about the grammar and syntax of sudoers rules.

More details on sudoers are outside OP's scope, but for the sake of being a little more complete, just 2 more comments.

1) RULE PATTERN FOR sudoers

# who where = tags:(as_whom) what
# "who" is either a group or a collection of users
# "where" is a host or a collection of hosts
# "tags" is the permission granted to "what" is being allowed
# "as_whom" specifies under whose guise the cmd(s) are executed;
#   can be a user "user:" or a group ":group" 
#   or a user and group "user:group"
# "what" is a cmd or a collection of cmds

2) WARNING: messing with sudoers may end up with a user either smiling or creating a security black hole or making himself and others unable to access sudo altogether. In the latter case, with this you can still go home in the evening and have yr cake too. Make sure you know what you are doing.

The above tests well for me on a plain vanilla 14.04.4 LTS Desktop, but can be further hardened security wise. Doing so is not terribly complicated, but again it falls outside the scope of this question.
HTH

Cbhihe
  • 2,761
  • 3
  • 24
  • 47
  • +1 for the extensive answer. However, running with sudo did (strangely) result in the same error after giving me first this warning 'IBUS-WARNING **: The owner of /home/bruni/.config/ibus/bus is not root!' – Bruni Jul 03 '16 at 18:06
  • I did run sudo on the cli (with the .ffs_batch file). I now also tried gksudo and the message is the same. – Bruni Jul 03 '16 at 20:45
  • 1
    @Bruni: I am back. Create a test batch file for a simple job. For instance the job can consist of 2 files with different names AA and BB, one on yr mounted volume, the other stored in yr local system. Can you try from cli: sudo -i /usr/bin/FreeFileSync "${HOME}"/.FreeFileSync/backup-jobref.ffs_batch 2> "${HOME}"/.FreeFileSync/backup-jobref.ffs_log ? For me this works well. man sudo to understand the flag -i. Hope there will be some progress here. – Cbhihe Jul 07 '16 at 17:53
  • Indeed we have some progress here. The sync worked. Though now all these files are owned by root. The log file contains an unrelated error message (ttyname failed: Inappropriate ioctl for device) – Bruni Jul 08 '16 at 08:24
  • Ok, I tried the gui sync running as bruni, and selected with "ignore" after the Cannot set directory lock for "/path/to/mountpoint" and it worked. So it seems root is only required to set the directory lock. I am not sure however if this is dangerous when used in a production environment... – Bruni Jul 08 '16 at 08:53
  • @Bruni: It is normal behavior for FreeFileSync when invoked via sudo (DTBT ;-)). See if you can sudo -i -g bruni ....and get the primary group as bruni. However I am afraid that using FreeFileSync, you WILL NOT be able to conserve original user- and group-ownership of yr backedup file, e..g. the way that rsync -a ... would. FFS is not the right tool for that. I speak from experience. In any case this is not part of OP unless you change them. You might want to start a new specific thread on that question. – Cbhihe Jul 08 '16 at 09:02
  • @bruni: It is a dangerous shortcut when in production. If anything, un-mounting yr volume while being used by FFS would wreak havoc in yr backup. It's happened to me before. However a simple automated script can make sure that yr mounted volume may not be umounted when while being used by FreeFileSync. It looks like you have what you want in the end, but may I ask you: WHY FFS ? It is rather rudimentary compared to rsync. – Cbhihe Jul 08 '16 at 09:09
  • I do not really use this as a backup in the narrow sense. The point is, all files are on the server. However, we do not always have internet access when going to a client. Hence, I use FFS to sync before going to a client and again after returning. I am (at the moment) the only one using Ubuntu on the team (I don't work in IT) and FFS is cross platform and GUI and therefore easy to explain to less technical users. But if rsync is more secure (with regard to data integrity), I will look into it. BTW I really appreciate the time you put into this. – Bruni Jul 08 '16 at 09:22
  • @Bruni: No worry ! But thanks for mentioning it. -- Good point about FFS being cross-platform. It is why I first used it at the time I still had mixed (dual-boot) environments. Since then I wiped Windows off the face of my small farm and I graduated to rsync. If you really want gui, try using grsync from the Ubuntu repo. it is a graphical interface for rsyncalthough not cross-platform. Quoting from a user: "[grsync is] Highly configurable and very effective. Simpler than Deja-Dup. Comparable to SyncBack on Windows." <= that sums it up for you. Good luck ! – Cbhihe Jul 08 '16 at 09:31