With remote storage becoming the amazing and value added service it is, having a backup of your files has become a “there is no reason I don’t have one” anymore. While I am a firm believer and follower of the rule of three backups.
- Local Backup
- External Drive/LAN Backup
- Remote Backup
Now because I have lost data due to a lightening strike, and not having offsite backups, I live and breathe backups. However I have two remote / offsite backups.
With this, I am going to encourage if your using Windows or Mac’s grab you Mountain Duck from Mountainduck.io and use it, its well worth the $35 to use it, plus they have a 14 day trial to make sure.
Now back to Linux, I have tried several different pieces of software, scripts, plugins, all that, but nothing really worked the way I wanted it to. I want to mount a “drive” or a “folder” and access it just like I do my other folders and directories, no matter it a working live folder or a mount as a storage folder.
Introduce rclone. rclone.org – rclone allows you to mount a vast array of remote storage options as local mounts.
Today we are going to focus on sFTP/SSH as this is becoming the “goto” type of backups. For our example we are going to us HostBrr’s storage box that is based out of Salt Lake, Utah and currently you can get 500GB’s of storage space for $7.77 a year! https://my.hostbrr.com/order/forms/a/MTExMTc=
After you sign up, you will get your welcome email which will contain your credentials you will need.
Now lets get your system setup!
Lets dive on into your backups!
** Assumptions are going to be made now.
** You understand basic Linux commands.
** Your working in your vps, server that your wanting to mount this drive on.
1. Installation
apt install rclone fuse
Create dirs.
mkdir /backups
mkdir /mnt/.cache
2. Configuration
If you’re running it on a VPS, you can use:
rclone config
If you’re running it on home desktop, you can open a web GUI, using:
rclone rcd --rc-web-gui
Then fill this input:
To make it easy I will use the email content I get from HostBrr as reference.
name = storage-sftp
storage type = sftp
host = [Storage Server IP-address]
username = [Username]
port = [Find this: You must use port ***** for SSH]
password = [Password]
Ignore the rest of inputs.
Fill the port with 22 if you’re not using hostbrr.
3. Running the rclone
rclone mount storage-sftp:/home /backups --daemon \
--dir-cache-time 72h --cache-dir=/mnt/.cache \
--vfs-cache-mode full --vfs-cache-max-size 10G
And boom! your storagebox is now available locally!
You can now browse and copy paste on /
backups just like it’s a local storage. You can also watch videos from this storage with minimal hiccups.
No need to wait the upload to finish, you can edit the files on the fly while they’re being uploaded in the background.
But it’s not done yet, because when you reboot, rclone will close and you need to run it again.
4. Run rclone at every boot
These steps will make sure that the rclone service runs after booting, using systemd.
First, make sure the directory is unmounted.
fusermount -u /backups
Create systemd service.
nano /etc/systemd/system/storage.service
Paste this, edit if needed:
[Unit]
Description=rclone mount
AssertPathIsDirectory=/backups
After=network-online.target
[Service]
Type=notify
ExecStart=rclone mount storage-sftp:/home/username/folder /backups \
--dir-cache-time 72h --cache-dir=/mnt/.cache \
--vfs-cache-mode full --vfs-cache-max-size 4G
ExecStop=/bin/fusermount -u /backups
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Then enable and restart the service:
systemctl daemon-reload
systemctl enable storage
systemctl restart storage
Make sure the service is running:
systemctl status storage
Test by reboot
the system.
That’s it, now the /backups
will always available.
