Python wrapper to access and control an UrBackup server
Project description
Python UrBackup
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:
pip3 install python-urbackup
To update the "Usage" section of your GitHub README, we can provide a more detailed and structured snippet that reflects the initialization, login, and some common operations with the urbackup_server
class. Here is the revised "Usage" section that can be added:
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
backup_server = urbackup_server('your_server_url', 'your_username', 'your_password')
Logging In
To perform any operations, you need to log in:
if backup_server.login():
print("Login successful!")
else:
print("Login failed!")
Getting Client Status
Retrieve the status of a specific client:
client_status = backup_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 backup_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 backup_server.start_incr_file_backup('client_name'):
print("Incremental file backup started successfully.")
else:
print("Failed to start incremental file backup.")
if backup_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 = backup_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.
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for python_urbackup-0.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | dbd1997a96f6a407059858454798a8f9aa82e232a28b09efbafd84646f83976c |
|
MD5 | ce2400659c848542ca18a90b7044fd78 |
|
BLAKE2b-256 | 9013c7065699595130faf38826971bd47de1dda4a5b5f4776e2cde486735d3b6 |