I'd like to automount an FTP folder using curlftpfs
putting in fstab
a row like:
curlftpfs#user:pwd@myhost:port/folder/ /mnt/mymountfolder fuse allow_other,uid=1000,gid=1000,umask=0022,_netdev 0 0
Normally it wouldn't work, as during the boot the network (wifi usually) is not available for my laptop. I read that _netdev
option in fstab should ensure the mounting only when the network is available, but I receive the message:
Error connecting to ftp: Couldn't resolve host myhost
Alternatively I could mount the resource with an autorun script after the login has been made, but I'd like much more the fstab solution.
The final goal is to syncronize a local folder with the ftp folder with a crontab rsync, so if you have other suggestions, I will be grateful!
As your goal is "to syncronize a local folder with the ftp folder with a crontab rsync", I suggest you to write a small script that mounts the FTP, rsync, unmount FTP. Then run this script from crontab.
It should go something like this:
Make sure you chmod +x on the script.
crontab -e
Also, if you really want the FTP folder mounted all the time, you could make a script that mounts/unmounts your drive. If you also add it to fstab, you could manually mount the drive.
fstab:
network-mount.sh:
Add this to crontab (crontab -e):
Also watch out for your rsync not completing before the next is run. This could be done automatically(check if rsync running), or based upon how much data that need to be in sync(amount of time rsync takes, worst case scenario).
Assuming you don't run rsync for anything else, checking if it's running could be done like this:
I'm using SFTP / sshfs for that purpose
Not sure if there is a fstab way. If you execute a cron job doing this every x minutes, would be ok. If the folder is already mounted, you will just get "already connected" error. If you are disconnected, you will get another error and no connection will be made. But when you are connected again, you will connect in a minute... In case of cron job you can remove
-o reconnect
part.Make the script file secure as it contain the password.
You may try curlftpfs option
In your example (let us say 30 secs are enough),
Alternatively, you can remove from fstab and connect in Nautilus, then save it as bookmark and connect each time you startup.