This tutorial helps to mount remote backup space with ssh access locally to OpenVZ VMs. Using this method we can save backups locally and to the remote server at the same time. This will help to reduce the remote file transfer time, CPU overload and usage of paid backup transfer services.
1. In order to enable FUSE/SSHFS on VPS we need to confirm that FUSE module is enabled on the hardware node on which the VPS is hosted.
Commands to enable FUSE on the hardware node.
# modprobe fuse
Check whether the module is loaded properly or not.
# lsmod | grep fuse
2. Fuse and sshfs are not available with default RHEL repo. We need to enable the EPEL repo on VPS to include the required packages.
yum install epel-release -y
3. Install FUSE and SSHFS packages on the VPS.
SSHFS uses FUSE (Filesystem in userspace). Install the required packages.
yum install fuse sshfs -y
4. Enable FUSE for VPS (from the hardware node)
# vzctl set vpsid –devnodes fuse:rw –save
Restart the VPS to update the file system and make sure ‘fuse’ exists under /proc/filesystems
[root@openvz-vps /]# cat /proc/filesystems
5. Enable incremental/normal backup on the source server from WHM (If it is a cPanel server).
6. Create the corresponding user on the destination server. For e.g. ‘user_name’.
[root@destination_server]# useradd user_name
[root@destination_server]# passwd user_name
Changing password for user user_name.
Retype new password:
passwd: all authentication tokens updated successfully.
7. Now mount the remote backup space using the sshfs command below. The command will ask the password of the user created on the remote server.
[root@voda16 /]# sshfs -o ServerAliveInterval=15 -o cache_timeout=600 -o uid=0 -o gid=0 user_name@destination_server_ip:/home/user_name/weekly/ /backup/cpbackup/weekly/
This will replicate the files/backups saved under /backup/cpbackup/weekly/ to the remote server’s backup space instantly (in this case, it will be replicated to /home/user_name/weekly/).
# Check the result of ‘df’ command to verify the settings.
[root@openvz-vps /]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/simfs 3.0T 1.7T 1.3T 57% /
devtmpfs 4.0G 0 4.0G 0% /dev
tmpfs 4.0G 0 4.0G 0% /dev/shm
tmpfs 4.0G 364K 4.0G 1% /run
tmpfs 4.0G 0 4.0G 0% /sys/fs/cgroup
user_name@destination_server_ip:/home/user_name/weekly/ 22T 18T 2.7T 88% /backup/cpbackup/weekly