Mount filesystem using ssh or ftp
How to mount a remote filesystem using a SSH or FTP connection
The original instructions provided by the Gentoo wiki are here.
Mount using a ssh connection
First of all download and install fuse and sshfs-fuse:
emerge -av sys-fs/fuse
emerge -av sys-fs/sshfs-fuse
Then start fuse and check if it loaded successfully:
modprobe fuse
dmesg (check what the last lines say)
lsmod (check if fuse is listed somewhere)
Now that it has been loaded, mount the remote filesystem. To mount the remote directory /home/shared/myvideos stored on the machine 10.0.0.34 to the local directory /mnt/remotevideos I type:
sshfs root@10.0.0.34:/home/shared/myvideos /mnt/remotevideos
When you're done you can unmount it using:
fusermount -u /mnt/remotevideos
Mount using a ftp connection
Download and install lufs, lufis and fuse
emerge -av lufs lufis fuse
Start the fuse module
modprobe fuse
Then mount the remote filesystem (e.g. a webpage):
lufis fs=ftpfs,host=ftp.myhost.com,username=itsme,password=mypassword12 /mnt/homepage/ -s
That's it - now you should be able to see the directory structure of your homepage in /mnt/homepage. This is very handy when you want to do backups using rsync or rdiff-backup, especially when the connection to the provider of your homepage is very slow (like mine) as rdiff-backup will do a backup of only what has changed since the last backup, therefore not downloading the whole thing again and again. Originally I used to do 1:1 copies of my homepage which took each time about 45 minutes, but now it works in not even 5 minutes!!! I love it... .
To unmount use again the same command as before:
fusermount -u /mnt/homepage
All in all, a simple backup_homepage-script would look like this:
#!/bin/bash
lufis fs=ftpfs,host=ftp.myhost.com,username=itsme,password=mypassword12 /mnt/homepage/ -s && rdiff-backup \
--verbosity 6 /mnt/homepage/ /home/backups/backup_homepage/ @@ echo "Backup homepage finished"
fusermount -u /mnt/homepage/ @@ echo "Filesystem unmounted"
A last recommandation concerning the FTP-method: if after a while your commands seem to hang, it's probably because you've been inactive too long and the host disconnected you => you'll need to unmount and re-mount the connection. I tried to find some kind of "keep alive" setting, but didn't manage to. A possible workaround would probably be a script that after mounting the connection issues "ls" commands on any remote directory every minute or so.
