Use a Samba (SMB/Cifs) Share as Datastore in Proxmox Backup Server

Problem

Although Proxmox Backup Server (PBS) is designed to be used with local storage it might be a good choice for you to remotely store your data. NFS and SMB/Cifs are viable choices. For both there is no GUI-ready solution. You need to do it via command line and standard Linux tools. I will focus on SMB/Cifs right now.

Solution

Login to your PBS and follow these steps:

Install needed packages:

$ sudo apt install cifs-utils

Create a credentials file that holds the information to access the SMB share:

# Content of /root/.pbs_smb_share_secrets
username=xyz
password=123

Make the credentials file less accessable:

$ sudo chmod 640 /root/.pbs_smb_share_secrets

Mount the SMB share:

# Create a directory that will be used as mountpoint
$ mkdir /mnt/pbs_smb_share
# Add a line to the fstab file
$ sudo echo "//IP_OF_SMB_SERVER/DIRECTORY_ON_SERVER /mnt/pbs_smb_share cifs rw,auto,uid=34,noforceuid,gid=34,noforcegid,credentials=/root/.pbs_smb_share_secrets 0 0" >> /etc/fstab
# Remount mounts
$ sudo mount -a

The uid and gid are the ones belonging to the user backup on the PBS system. Don’t miss that one. You will end up in permission errors either when creating the datastore or later when creating backups or starting the garbage collection (like “unexpected error on datastore traversal: Permission denied (os error 13)”) as one example.

Create the datastore on PBS:

$ sudo proxmox-backup-manager datastore create \
      NAME \
      /mnt/pbs_smb_share \
      --comment 'Backup directory based on smb/cifs'

Software version used

Proxmox Backup Server: 2.2

Leave a Comment