Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Databases: add support for zip archiving #97

Merged
merged 7 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ databases:

## Databases

Right now, this app supports **MongoDB**, **PostgreSQL 13**, **MariaDB**, **Redis** and **Zip archiving**. If
Right now, this app supports **MongoDB**, **PostgreSQL 13**, **MariaDB**, **Redis** and **LocalStorage archiving**. If
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this feels weird, and may be confused with localStorage, the HTML5 feature.

Let's just make it local storage archiving without capital letters.

you need support for an additional database, consider opening a pull request to
add a new database handler.

Expand Down Expand Up @@ -371,14 +371,21 @@ Identifiers can be any string of your choosing.
port: "6379"
```

### Zip archiving
### Local Storage
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's do Local storage here.


- **Database type**: `zip`
- **Database type**: `localstorage`
- **Required field**: `path`
- **Optional field**: `compression_level`
- The compression level must be an integer between 0 and 9.
- The archive will contain the full structure, starting from the root folder.

```yaml
localstorage:
main_localstorage:
path: /path/to/folder
compression_level: 7
```

#### To restore from the backup

- Stop Redis server.
Expand Down
2 changes: 1 addition & 1 deletion blackbox/handlers/databases/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
from .mysql import MySQL
from .postgres import Postgres
from .redis import Redis
from .zip import Zip
from .localstorage import LocalStorage
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from blackbox.handlers.databases._base import BlackboxDatabase


class Zip(BlackboxDatabase):
class LocalStorage(BlackboxDatabase):
"""A Database handler that will zip a local folder."""

required_fields = ("path",)
Expand Down Expand Up @@ -38,4 +38,5 @@ def backup(self) -> Path:
elif file.is_dir():
directories.append(file)

self.success = True
return backup_path