Python script for remove client


I would like to remove a urbackup client from the urbackup server with the urbackup_api in python.

It’s possible to do this ?

Thanks for your help


I’m not into Python so I can’t give you the exact code for Python wrapper, but you definitely can do it with UrBackup web API.

Just in case you don’t mind JavaScript I will shamelessly plug Node.js wrapper. Let me know if you need any assistance with that one.

The short awnser should be:


Assuming you’ve got some python scripts for the API already setup that setup and define the server connection as “server”.

Hi @MWubbema are you sure it works for removing clients (and not only „extra clients”)?

I don’t know Javascript but I will test your solution but if you have more help to give me in Javascript, I am taker

I test remove_extra_client and isn’t work for remove client

OK @Erick here is what you need to do.

Create a new project and install UrBackup API wrapper:

npm install urbackup-server-api

Create a new index.js file in the same directory. That index.js should look like that:

const { UrbackupServer } = require('urbackup-server-api');

const server = new UrbackupServer({ url: '', username: 'admin', password: '' });

(async () => {
  try {

    //your code goes here

  } catch (error) {

Adjust url, username and password if needed. You don’t have to run it on the backup server itself, it can be on any machine that can pass through your firewall.
You can copy/paste code examples from docummentation in place of ‘//your code goes here’.

To get a list of clients with their ID and name, paste:

server.getClients().then(data => console.log(data));

To remove a client replace your code with:

server.removeClient({clientId: 1}).then(data => console.log(data));
// or
server.removeClient({clientName: 'laptop2'}).then(data => console.log(data));

Run script with:

node index.js

Two things to keep in mind. Removing a client will also REMOVE BACKUPS belonging to that client. Actual removing happens in the cleanup window configured on your server, until then clients are marked for deletion and backups are still on disk.

Hi @Michal

Thanks for your help, I have successfully done this script in node.js.
but my problem is that node.js requires an installation of additional tools in addition to this already installed for python on my script server

I do my fisrt node.js script thanks for that


It’s OK in node.js but anyone have a solution in python with urbackup_api ?

Hi Erick, sorry for the wrong command earlier…

It should be pretty easy to convert the above to python:

import urbackup_api
import time
import datetime
server = urbackup_api.urbackup_server("", "admin", "yourpaswordhere")

however I don’t see a urbackup API definition for this function. So you’d have to modify the file for the local copy of your python urbackup api and add something like the following:

def removeclient(self, clientname):
        if not self.login():
            return None

        client = self.get_client_status(clientname)

        if client == None:
            return None

        clientid = client["id"];

        ret = self._get_json("status", {"remove_client": clientid } );
        if not ret:
            return False
        return True

That should do the trick :slight_smile:

@Erick You are right, a lot of extra stuff is needed which is usually not recommended on a server.

That is why I do it on my admin workstation so I can access all my UrBackup servers from one place, zero additional packages on the servers.

If there is a need to do use it directly on the server then I’m using a packaged form of custom CLI tool, where everything - Node, dependencies, my scripts, configuration - is compiled into one executable file. Again, no extra dependencies on the server, I just need to provision one file.

Naturally, all that is a lot of work if you already have a Python setup, better just stick to that :slight_smile:

Hi @MWubbema

Thank you very much for this code, you are the Man
I would never attempt to edit the original file and I wouldn’t even know how to do it.

It works fine. :ok_hand:

Thanks :pray:

Hi @Michal

Thanks a lot for your explanation, I wrote my first node.js script, thanks to you!! :pray: