[QUESTION] One datastore per customer with a quota

NFLJct3Dtp

New Member
Apr 27, 2023
4
0
1
Good morning,

I'm new to Proxmox Backup Server.
I am taking over a project in the company where I work.

Currently we have more than 150 Proxmox Virtual Environment servers, we are deploying an appliance of an application that we have developed.

Currently we just have local backups with vzdump.

For security reasons I want to do outsourced backups with Proxmox Backup Server, I would like to have one account per client with a datastore with a quota set at 150G.

From what I have been able to understand it is better to use ZFS and do datastore by client unfortunately I have not found any documentation to do this and if possible to do it via the API.

I found the endpoint to create a ZFS pool but not to create a datastore for each client with a quota.

https://pbs.proxmox.com/docs/api-viewer/index.html#/nodes/{node}/disks/zfs

Thank you for your help
 
Ok I found.
To create the ZFS pool there is endpoint in API but to create the dataset with API I found nothing

Create the ZFS pool with the 3 disks:
Code:
zpool create testpool raidz /dev/sde /dev/sdf /dev/sdg

Check that the pool has been created:
Code:
root@pbs:~# zpool status testpool
  pool: testpool
 state: ONLINE
config:

        NAME        STATE     READ WRITE CKSUM
        testpool    ONLINE       0     0     0
          raidz1-0  ONLINE       0     0     0
            sde     ONLINE       0     0     0
            sdf     ONLINE       0     0     0
            sdg     ONLINE       0     0     0

errors: No known data errors

Create a dataset in the pool and give it a quota of 10GB:
Code:
zfs create -o quota=10G testpool/client01

Check that the dataset has been created and the quota is set:
Code:
root@pbs:~# zfs list
NAME                USED  AVAIL     REFER  MOUNTPOINT
rpool              1.23G  28.8G       96K  /rpool
rpool/ROOT         1.22G  28.8G       96K  /rpool/ROOT
rpool/ROOT/pbs-1   1.22G  28.8G     1.22G  /
tess               24.7M  30.5G     24.3M  /mnt/datastore/tess
testpool           9.12M  61.6G     30.6K  /testpool
testpool/client01  8.91M  9.99G     8.91M  /testpool/client01
testpool/client02  30.6K  10.0G     30.6K  /testpool/client02
 
Last edited:
dataset management is not integrated like that in PBS. you need to create the datasets yourself, and then you can create the datastores on top using the API/CLI.
 
  • Like
Reactions: NFLJct3Dtp
I am looking to automate the process of creating a dataset with a quota and using it as a datastore in Proxmox Backup Server. If it is not possible to manage the dataset directly from Proxmox API, my plan is to:

First, establish an SSH connection to the Proxmox Backup Server and execute a ZFS command to create the dataset with the desired quota.
Once the dataset is created, use the Proxmox Backup Server API to create the datastore with the POST /api2/json/config/datastore endpoint.

Do you have a better solution or an improvement idea?

Exemple:
PHP:
<?php
$host = 'remote.server.com';
$user = 'username';
$key_path = '/path/to/ssh/key';

$connection = ssh2_connect($host);
ssh2_auth_pubkey_file($connection, $user, $key_path . '.pub', $key_path);

$command = 'zfs create -o quota=10G testpool/client01';
ssh2_exec($connection, $command);
?>
 
Last edited:
yes, that approach should work (I am not a PHP dev, so can't say anything about the code snippet ;)). you could also use proxmox-backup-manager to create the datastore instead of using the API - but they do the same thing under the hood anyway :)
 
  • Like
Reactions: NFLJct3Dtp
@fabian Thanks

@tuxis I saw that you offer backup as a service, do you have any advice? How do you manage the automatic creation of the dataset since it is not possible to do it from the API?
 
We do not that automagically. We have a script that creates users and datastores and sets the quota using zfs tooling.

AFAIK there is no ZFS API anywhere (yet).