Proxmox Backup Server & Synology NFS

Proxmox Backup Server & Synology NFS
Screenshot of real instance

Introduction

As I delved deeper into working with Proxmox and expanded my array of containers and virtual machines, which began to prove beneficial, the need for backup solutions became apparent. Proxmox was well-equipped to handle this need. It comes with its own product that seamlessly integrates with Proxmox VE - the Proxmox Backup Server (PBS).

Proxmox Backup Server
Proxmox Backup Server is an enterprise backup solution, for backing up and restoring VMs, containers, and physical hosts.
Proxmox Backup Server is an enterprise solution for backing up and restoring virtual machines (VMs), containers, and physical hosts. By supporting incremental, fully deduplicated backups, Proxmox Backup Server significantly reduces network load and saves valuable storage space. With reliable encryption and data integrity assurance methods, you can feel secure when backing up data, even data you may not fully trust. - Official Website

Understood, I'll have to give this a try. But files need to be stored somewhere, especially when it comes to backups, so it's better to do it on a separate server, which I didn't have...

The Idea

After reviewing all the aspects, I chose not the best but the most suitable way for myself - I will install Proxmox Backup Server as a virtual server on Proxmox VE, but having a Synology NAS, it was decided to use it for storing files.

The essence is that I really didn't have a separate server with dedicated drives specifically for backups. But I have Proxmox VE and I have a NAS.

Proxmox VE will serve as the foundation for running Proxmox Backup Server as a full-fledged server, while the NAS will separately store the files.

Could both the backup server and its storage be virtualized? Yes! But when both the containers we plan to backup and the backup server store their files on the same physical device, it completely devalues the attempt to improve the fault tolerance of the entire system. It logically doesn't make sense. If everything runs on one physical server and your SSD/HDD fails, you will lose everything. Under these conditions, you don't need PBS; you can easily make backups to the local storage of Proxmox VE.

In my case, Synology NAS (and for you, it could be any network-attached storage) is very suitable for the role of an independent and stable device for backups.

Installation and Configuration

This is the section where I don't want to repeat other authors. There is a very good article on how to install PBS, configure NFS, and connect everything, as well as how to enable regular backups. I went through all the steps and managed to configure everything I needed. I'm sharing this wonderful post by Derek Seaman with you:

How To: Setup Synology NFS for Proxmox Backup Server Datastore - Derek Seaman’s Tech Blog
This post covers deploying a Proxmox Backup Server (PBS) and using a Synology NAS NFS mount as a datastore for backups. And optionally you can run the PBS server as a VM on your Synology NAS as well. Why would you want to use Proxmox Backup Server? Here are a few reasons:Built-in data deduplication. I’m

But don't think that's all. There are nuances to consider.

Below, I've listed the main commands I executed on the installed backup server. My NAS has the address 192.168.1.52.

# create dir
cd /mnt
mkdir synology

# access
chown backup:backup /mnt/synology
chmod 775 /mnt/synology

# check mounts
mount -a

# add to fstab
echo “192.168.1.52:/volume1/pbs /mnt/synology nfs vers=3,nouser,atime,auto,retrans=2,rw,dev,exec 0 0" >> /etc/fstab

# to make sure that the record was added correctly
nano /etc/fstab

# reload
systemctl daemon-reload

# (optional) create any file to verify that it's added on Synology NAS
touch /mnt/synology/testfile.txt

# create different folders for different Proxmox VE servers 
cd /mnt/synology
mkdir thor
mkdir stargate
Please carefully follow the steps for setting up Synology NFS. Mistakes in these steps can consume your time.

Structure

Directories

I want to explain the directory structure.

As in the main example from Derek Seaman, we will have a directory named "synology." It will represent the network storage located on our NAS. Initially, I connected it to Proxmox VE and was happy. However, later I acquired another Proxmox VE server located far outside the current network. After connecting and backing up other containers (sometimes with similar IDs or names), chaos ensued.

That's why I strongly urge you to create directories with the names of your Proxmox VE servers from the very beginning for convenience.

I have two: Thor (where the PBS itself is located) and Stargate (in another city).

Datastores

According to the directory structure, we need to create datastores. However, I created not two but all three: for each server and a shared one (the "synology" directory).

An advantage of this approach is that by connecting the datastore of the respective server and the shared Synology datastore, you can easily create backups from one server to the shared Synology datastore and use them on another server. This is convenient, especially for templates of virtual machines or containers.

Conclusion on Structure

All these actions are relevant when you have more than one Proxmox VE server. This structure and connection of multiple datastores offer the following advantages:

  1. Segregation of backups from different servers.
  2. Quick exchange of backups and templates.

Connection to a remote PBS.

Since my PBS and one of the Proxmox VE servers (Stargate) are located in different cities, I had to try connecting to a remote PBS.

A tunnel from Cloudflare with a public domain name, which many practice at home, works only as a web resource for the PBS server. This means you can only access and view the web interface. I may explain how to set up such a Cloudflare tunnel another time.

For the backup server to work properly, it was necessary to open a port other than 80 and 8443. On my router, I opened both TCP and UDP protocols on port 8007.

And separately configured DDNS. Do this if you haven't already, or use the address you set up earlier.

Again, I'm not trying to explain in detail how to do this correctly. Different routers will have different web interfaces and locations, and possibly different names. Learn more about setting up Port Forwarding and DDNS specifically for your router.

Having port 8007 open and remote access through a public DDNS domain, you'll easily be able to connect your PBS to the Proxmox VE server in another city.

For clarity, I've drawn a diagram to help understand.

Reconnection

After several power outages, I realized that the Proxmox Backup Server failed to reconnect to Synology during startup. Most likely, it starts up faster than when Synology NFS becomes available. That's why I had to log into the server several times and manually execute the reconnection command mount -a.

This is how I noticed that the scheduled task did not run as expected. It's frustrating.

Backup job fails

crontab

It immediately occurred to me that this task could be translated into a tool like crontab. It schedules the necessary command to run at specified intervals.

On the PBS server, in the shell, you would execute a command to open the crontab editor.

crontab -e

In the file that opened for editing, navigate to the very bottom and add the following line.

*/30 * * * * mount -a

It will look something like this.

Having made the addition, we save the changes and never have to return to this issue again.

For more details about crontab, I recommend reading here.

How To Use Cron to Automate Tasks on Ubuntu 18.04 | DigitalOcean
Cron is a time-based job scheduling daemon found in Unix-like operating systems, including Linux distributions. This guide provides an overview of how to sch…

Conclusion

I didn't encounter any issues setting everything up following the instructions of other authors, as it's already a well-established process. In my case, I faced challenges with directory structure and connecting to PBS located outside the current network. I've addressed these issues accordingly.

Regarding the directory structure, it's advisable to create separate directories and datastores for each Proxmox VE server. This approach is convenient, understandable, and even safer, especially if you take the extra step of creating different users with unique passwords.

However, connecting via port 8007 forwarded through the router is a hurdle that many people may face. Port forwarding through a router is a fairly trivial task in homelabbing. If you've never done it before, don't worry too much—it's not as daunting as it seems.

Just give it a try, and you'll succeed.

Read more