Skip to main content

Python wrapper to access and control an UrBackup server

Project description

Python UrBackup urbackup.org

PyPI PyPI - Python Version GitHub Actions Workflow Status Coverage Status Documentation Status

Python UrBackup is a powerful Python wrapper designed to interact with UrBackup servers. This library allows you to manage backups, restore operations, and monitor the server status programmatically.

Originally urbackup-server-web-api-wrapper

Installation

Install with:

pip install python-urbackup

Usage

Initialization

Create an instance of the urbackup_server by specifying the server URL, username, and password. Replace 'your_server_url', 'your_username', and 'your_password' with your server details:

from urbackup import urbackup_server

server = urbackup_server('your_server_url', 'your_username', 'your_password')

Logging In

To perform any operations, you need to log in:

if server.login():
    print("Login successful!")
else:
    print("Login failed!")

Getting Client Status

Retrieve the status of a specific client:

client_status = server.get_client_status('client_name')
if client_status:
    print(f"Client status: {client_status}")
else:
    print("Client not found or access denied.")

Downloading an Installer

To download an installer for a new client, specify the file path and the client's name:

if server.download_installer('path/to/installer', 'new_client_name'):
    print("Installer downloaded successfully.")
else:
    print("Failed to download installer.")

Starting Backups

You can start different types of backups for a client. Here are examples of starting an incremental file backup and a full file backup:

if server.start_incr_file_backup('client_name'):
    print("Incremental file backup started successfully.")
else:
    print("Failed to start incremental file backup.")

if server.start_full_file_backup('client_name'):
    print("Full file backup started successfully.")
else:
    print("Failed to start full file backup.")

Managing Clients

Add a new client to the server:

new_client = server.add_client('new_client_name')
if new_client:
    print("New client added:", new_client)
else:
    print("Failed to add new client.")

List clients with no file backup in the last three days:

import urbackup
import time
import datetime
server = urbackup.urbackup_server("http://127.0.0.1:55414/x", "admin", "foo")
clients = server.get_status()
diff_time = 3*24*60*60 # 3 days
for client in clients:
    if client["lastbackup"]=="-" or client["lastbackup"] < time.time() - diff_time:

        if client["lastbackup"]=="-" or client["lastbackup"]==0:
            lastbackup = "Never"
        else:
            lastbackup = datetime.datetime.fromtimestamp(client["lastbackup"]).strftime("%x %X")

        print("Last file backup at {lastbackup} of client {clientname} is older than three days".format(
              lastbackup=lastbackup, clientname=client["name"] ) )

For more information, please refer to the API Reference.

UrBackup CLI

The UrBackup CLI is a command-line interface that allows you to interact with the UrBackup server from a client machine.

Important Note: For Windows the command-line tool is urbackupclient_cmd. Mac and Linux use urbackupclientctl.

CLI options for urbackupclientctl and urbackupclientctl are as follows:

USAGE:

        urbackupclientctl [--help] [--version] <command> [<args>]

Get specific command help with urbackupclientctl <command> --help

        urbackupclientctl start
                Start an incremental/full image/file backup

        urbackupclientctl status
                Get current backup status

        urbackupclientctl browse
                Browse backups and files/folders in backups

        urbackupclientctl restore-start
                Restore files/folders from backup

        urbackupclientctl set-settings
                Set backup settings

        urbackupclientctl reset-keep
                Reset keeping files during incremental backups

        urbackupclientctl add-backupdir
                Add new directory to backup set

        urbackupclientctl list-backupdirs
                List directories that are being backed up

        urbackupclientctl remove-backupdir
                Remove directory from backup set

For more information, please refer to the UrBackup Administration Documentation.

Contributing 🤝

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

License 📃

This project is licensed under the Apache License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python-urbackup-0.1.2.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

python_urbackup-0.1.2-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

Details for the file python-urbackup-0.1.2.tar.gz.

File metadata

  • Download URL: python-urbackup-0.1.2.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.9.19

File hashes

Hashes for python-urbackup-0.1.2.tar.gz
Algorithm Hash digest
SHA256 64c9585e377d74d3e49c3f7e4a579cd88f3f2de506c0587cb89bbc43346a160d
MD5 e470fb5fb0bc6483e6f161bc662fe007
BLAKE2b-256 86c5b09f436e4545c6af5372a7a311b6364d1c342389f5813d34fa61c7107412

See more details on using hashes here.

File details

Details for the file python_urbackup-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for python_urbackup-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 c9a2f8cb2c148a54e7be74b66c0a0deb767a4e4d32c3063070db7c662d04fe28
MD5 f9e2e5915a7844a912b69396efcc6c01
BLAKE2b-256 0bdc7f4596dc5983c40128396254f82412d1fc424c6415754664a97f41bdfd95

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page