python-urbackup


Namepython-urbackup JSON
Version 0.1.2 PyPI version JSON
download
home_pagehttps://github.com/judahpaul16/python-urbackup
SummaryPython wrapper to access and control an UrBackup server
upload_time2024-04-30 21:42:49
maintainerNone
docs_urlNone
authorJudah Paul
requires_pythonNone
licenseApache License 2.0
keywords urbackup web api client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Python UrBackup [![urbackup.org](docs/urbackup.png)](https://www.urbackup.org/)

[![PyPI](https://img.shields.io/pypi/v/python-urbackup)](https://pypi.org/project/python-urbackup/)
![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dirconfig)
[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/judahpaul16/python-urbackup/workflow.yaml)](https://github.com/judahpaul16/python-urbackup/actions)
[![Coverage Status](https://coveralls.io/repos/github/judahpaul16/python-urbackup/badge.svg?branch=master&kill_cache=1)](https://coveralls.io/github/judahpaul16/python-urbackup?branch=master)
[![Documentation Status](https://readthedocs.org/projects/python-urbackup/badge/?version=latest)](https://python-urbackup.readthedocs.io/en/latest/?badge=latest)

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](https://github.com/uroni/urbackup-server-python-web-api-wrapper)*

## Installation

Install with:
```bash
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:

```python
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:

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

### Getting Client Status

Retrieve the status of a specific client:

```python
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:

```python
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:

```python
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:

```python
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:

```python
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](https://python-urbackup.readthedocs.io/en/latest/api_reference/).

## UrBackup CLI <img src="data:image/svg+xml,<svg fill='%234D4D4D' role='img' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><title>Windows Terminal</title><path d='M8.165 6V3h7.665v3H8.165zm-.5-3H1c-.55 0-1 .45-1 1v2h7.665V3zM23 3h-6.67v3H24V4c0-.55-.45-1-1-1zM0 6.5h24V20c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V6.5zM11.5 18c0 .3.2.5.5.5h8c.3 0 .5-.2.5-.5v-1.5c0-.3-.2-.5-.5-.5h-8c-.3 0-.5.2-.5.5V18zm-5.2-4.55l-3.1 3.1c-.25.25-.25.6 0 .8l.9.9c.25.25.6.25.8 0l4.4-4.4a.52.52 0 0 0 0-.8l-4.4-4.4c-.2-.2-.6-.2-.8 0l-.9.9c-.25.2-.25.55 0 .8l3.1 3.1z'/></svg>" width=20>

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:

```sh
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](https://www.urbackup.org/administration_manual.html).

## Contributing 🤝

Please read [CONTRIBUTING.md](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](LICENSE) file for details.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/judahpaul16/python-urbackup",
    "name": "python-urbackup",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "urbackup web api client",
    "author": "Judah Paul",
    "author_email": "me@judahpaul.com",
    "download_url": "https://files.pythonhosted.org/packages/86/c5/b09f436e4545c6af5372a7a311b6364d1c342389f5813d34fa61c7107412/python-urbackup-0.1.2.tar.gz",
    "platform": null,
    "description": "# Python UrBackup [![urbackup.org](docs/urbackup.png)](https://www.urbackup.org/)\n\n[![PyPI](https://img.shields.io/pypi/v/python-urbackup)](https://pypi.org/project/python-urbackup/)\n![PyPI - Python Version](https://img.shields.io/pypi/pyversions/dirconfig)\n[![GitHub Actions Workflow Status](https://img.shields.io/github/actions/workflow/status/judahpaul16/python-urbackup/workflow.yaml)](https://github.com/judahpaul16/python-urbackup/actions)\n[![Coverage Status](https://coveralls.io/repos/github/judahpaul16/python-urbackup/badge.svg?branch=master&kill_cache=1)](https://coveralls.io/github/judahpaul16/python-urbackup?branch=master)\n[![Documentation Status](https://readthedocs.org/projects/python-urbackup/badge/?version=latest)](https://python-urbackup.readthedocs.io/en/latest/?badge=latest)\n\nPython 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.\n\n*Originally [urbackup-server-web-api-wrapper](https://github.com/uroni/urbackup-server-python-web-api-wrapper)*\n\n## Installation\n\nInstall with:\n```bash\npip install python-urbackup\n```\n\n## Usage\n\n### Initialization\n\nCreate 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:\n\n```python\nfrom urbackup import urbackup_server\n\nserver = urbackup_server('your_server_url', 'your_username', 'your_password')\n```\n\n### Logging In\n\nTo perform any operations, you need to log in:\n\n```python\nif server.login():\n    print(\"Login successful!\")\nelse:\n    print(\"Login failed!\")\n```\n\n### Getting Client Status\n\nRetrieve the status of a specific client:\n\n```python\nclient_status = server.get_client_status('client_name')\nif client_status:\n    print(f\"Client status: {client_status}\")\nelse:\n    print(\"Client not found or access denied.\")\n```\n\n### Downloading an Installer\n\nTo download an installer for a new client, specify the file path and the client's name:\n\n```python\nif server.download_installer('path/to/installer', 'new_client_name'):\n    print(\"Installer downloaded successfully.\")\nelse:\n    print(\"Failed to download installer.\")\n```\n\n### Starting Backups\n\nYou can start different types of backups for a client. Here are examples of starting an incremental file backup and a full file backup:\n\n```python\nif server.start_incr_file_backup('client_name'):\n    print(\"Incremental file backup started successfully.\")\nelse:\n    print(\"Failed to start incremental file backup.\")\n\nif server.start_full_file_backup('client_name'):\n    print(\"Full file backup started successfully.\")\nelse:\n    print(\"Failed to start full file backup.\")\n```\n\n### Managing Clients\n\nAdd a new client to the server:\n\n```python\nnew_client = server.add_client('new_client_name')\nif new_client:\n    print(\"New client added:\", new_client)\nelse:\n    print(\"Failed to add new client.\")\n```\n\nList clients with no file backup in the last three days:\n\n```python\nimport urbackup\nimport time\nimport datetime\nserver = urbackup.urbackup_server(\"http://127.0.0.1:55414/x\", \"admin\", \"foo\")\nclients = server.get_status()\ndiff_time = 3*24*60*60 # 3 days\nfor client in clients:\n    if client[\"lastbackup\"]==\"-\" or client[\"lastbackup\"] < time.time() - diff_time:\n\n        if client[\"lastbackup\"]==\"-\" or client[\"lastbackup\"]==0:\n            lastbackup = \"Never\"\n        else:\n            lastbackup = datetime.datetime.fromtimestamp(client[\"lastbackup\"]).strftime(\"%x %X\")\n\n        print(\"Last file backup at {lastbackup} of client {clientname} is older than three days\".format(\n              lastbackup=lastbackup, clientname=client[\"name\"] ) )\n```\n\nFor more information, please refer to the [API Reference](https://python-urbackup.readthedocs.io/en/latest/api_reference/).\n\n## UrBackup CLI <img src=\"data:image/svg+xml,<svg fill='%234D4D4D' role='img' viewBox='0 0 24 24' xmlns='http://www.w3.org/2000/svg'><title>Windows Terminal</title><path d='M8.165 6V3h7.665v3H8.165zm-.5-3H1c-.55 0-1 .45-1 1v2h7.665V3zM23 3h-6.67v3H24V4c0-.55-.45-1-1-1zM0 6.5h24V20c0 .55-.45 1-1 1H1c-.55 0-1-.45-1-1V6.5zM11.5 18c0 .3.2.5.5.5h8c.3 0 .5-.2.5-.5v-1.5c0-.3-.2-.5-.5-.5h-8c-.3 0-.5.2-.5.5V18zm-5.2-4.55l-3.1 3.1c-.25.25-.25.6 0 .8l.9.9c.25.25.6.25.8 0l4.4-4.4a.52.52 0 0 0 0-.8l-4.4-4.4c-.2-.2-.6-.2-.8 0l-.9.9c-.25.2-.25.55 0 .8l3.1 3.1z'/></svg>\" width=20>\n\nThe UrBackup CLI is a command-line interface that allows you to interact with the UrBackup server from a client machine.\n\n*Important Note: For Windows the command-line tool is `urbackupclient_cmd`. Mac and Linux use `urbackupclientctl`.*\n\nCLI options for `urbackupclientctl` and `urbackupclientctl` are as follows:\n\n```sh\nUSAGE:\n\n        urbackupclientctl [--help] [--version] <command> [<args>]\n\nGet specific command help with urbackupclientctl <command> --help\n\n        urbackupclientctl start\n                Start an incremental/full image/file backup\n\n        urbackupclientctl status\n                Get current backup status\n\n        urbackupclientctl browse\n                Browse backups and files/folders in backups\n\n        urbackupclientctl restore-start\n                Restore files/folders from backup\n\n        urbackupclientctl set-settings\n                Set backup settings\n\n        urbackupclientctl reset-keep\n                Reset keeping files during incremental backups\n\n        urbackupclientctl add-backupdir\n                Add new directory to backup set\n\n        urbackupclientctl list-backupdirs\n                List directories that are being backed up\n\n        urbackupclientctl remove-backupdir\n                Remove directory from backup set\n```\n\nFor more information, please refer to the [UrBackup Administration Documentation](https://www.urbackup.org/administration_manual.html).\n\n## Contributing \ud83e\udd1d\n\nPlease read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests.\n\n## License \ud83d\udcc3\n\nThis project is licensed under the Apache License - see the [LICENSE](LICENSE) file for details.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache License 2.0",
    "summary": "Python wrapper to access and control an UrBackup server",
    "version": "0.1.2",
    "project_urls": {
        "Homepage": "https://github.com/judahpaul16/python-urbackup"
    },
    "split_keywords": [
        "urbackup",
        "web",
        "api",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0bdc7f4596dc5983c40128396254f82412d1fc424c6415754664a97f41bdfd95",
                "md5": "f9e2e5915a7844a912b69396efcc6c01",
                "sha256": "c9a2f8cb2c148a54e7be74b66c0a0deb767a4e4d32c3063070db7c662d04fe28"
            },
            "downloads": -1,
            "filename": "python_urbackup-0.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f9e2e5915a7844a912b69396efcc6c01",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10727,
            "upload_time": "2024-04-30T21:42:47",
            "upload_time_iso_8601": "2024-04-30T21:42:47.610419Z",
            "url": "https://files.pythonhosted.org/packages/0b/dc/7f4596dc5983c40128396254f82412d1fc424c6415754664a97f41bdfd95/python_urbackup-0.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "86c5b09f436e4545c6af5372a7a311b6364d1c342389f5813d34fa61c7107412",
                "md5": "e470fb5fb0bc6483e6f161bc662fe007",
                "sha256": "64c9585e377d74d3e49c3f7e4a579cd88f3f2de506c0587cb89bbc43346a160d"
            },
            "downloads": -1,
            "filename": "python-urbackup-0.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "e470fb5fb0bc6483e6f161bc662fe007",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11408,
            "upload_time": "2024-04-30T21:42:49",
            "upload_time_iso_8601": "2024-04-30T21:42:49.270039Z",
            "url": "https://files.pythonhosted.org/packages/86/c5/b09f436e4545c6af5372a7a311b6364d1c342389f5813d34fa61c7107412/python-urbackup-0.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-30 21:42:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "judahpaul16",
    "github_project": "python-urbackup",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "python-urbackup"
}
        
Elapsed time: 0.31084s