One project I had undertaken a couple years ago was part of my solution to reduce peripheral connections on my laptop, being very mobile. While the Synergy Project solved my keyboard and mouse problems, there was still the issue with backups. After having lost a hard drive in my desktop computer, I was reminded of the importance of backing up data, even if it is seemingly unimportant. After finally getting around to setting it up, I chose to use Déjà-dup (for quick and simple backups) onto Ubuntu One Drive, which offered something like 2GB of online storage. Simple.
Unfortunately, after about a couple months of this, I get a notification that Ubuntu’s cloud storage services will be cancelled, and to look for alternatives. Great. After motivating myself to finally backup, the setup I had in place would no longer be effective. I knew I needed to backup, but I very much dislike the idea of repeatedly plugging in and mounting an external USB HDD just for this.
After a bit of searching, I discovered tools that would solve the problem for me. Originally, this was a combination of NFS (network filesystem), and AutoFS (automatic filesystem). This allowed me to have an external USB HDD connected to another computer on my network (in my case a ‘server craptop’). From this, my daily driving laptop will automatically mount the partition as needed, and perform backups all in the background. No hassle, and no forgetting.
Once I migrated to Arch from Ubuntu, I had to re-configure the backups, and (to no surprise) it took me about a month to do this. While going over guides to recall how I had setup autofs, I discovered I no longer needed it, and could mount the partition using available services and mounting options. The following is how it works.
On my craptop, I have nfs installed, and configured the /etc/exports file with the following entry:
The * indicates what IP address it will be hosted on. While I tried different IP configurations, the star seemed to be the only one that worked (using a static IP for the craptop). rw is for read-write, sync to make sure changes are properly synchronized between client and server (don’t want to lose backup data), and no_subtree_check since only part of the drive is being mounted and used. Executing exportfs -r may be required to reload the settings.
Since an external drive is being used, this must be mounted onto the network drive path. I added an entry to my /etc/fstab to do this:
UUID=<uuid-of-drive> /path/to/network/drive ext4 auto,rw,sync 0 1
The auto option is used since it’s possible the USB drive may not be available immediately upon mounting.
While in the past I had used Autofs to mount, I discovered that this can be done directly by adding an entry to the /etc/fstab as follows:
<server-ip>:/path/to/network/drive /local/network/drive nfs rw,noauto,x-systemd.automount,x-systemd.device-timeout=10,timeo=14,x-systemd.idle-timeout=1min 0 0
With this, the partition is automatically mounted when available and being accessed.