Universal backup and recovery using S3 repo
Project description
Ubarec
The utility is designed for backup and restore databases to S3 storage. So far, PostgreSQL and MS SQL databases are supported.
Install
Ubuntu
The basic dependencies and package are easy to install:
sudo apt install -y p7zip-full unixodbc-dev python3.8 python3-pip && python3.8 -m pip install ubarec
When working with MS SQL, you must install the appropriate ODBC driver.
Windows
The program uses the console archiver 7-Zip, which should be pre-installed in any convenient way, for example, with the chocolatey:
choco install 7zip
The module is installed from the environment with administrator privileges:
py -m pip install ubarec
Working principle
In backup mode Ubarec performs the following actions for each of the databases specified in the command line parameters
- forms database dump (either by executing SQL script or using standard utilities)
- archives the dump using 7zip; if the
UBAREC_ZIP_PASSWORD
environment variable is set, the archive is password-protected - the created archive is copied to the S3-storage
- files created during the previous stages are deleted
The formed database archive has a file name by mask:
The current hostname>__<DB name>__<Time Label>.zip
In recovery mode Ubarec performs the following algorithm:
- searches for the last archive of the specified database in the S3 storage
- copies the found archive to a temporary folder
- unpacks the archive using the
UBAREC_ZIP_PASSWORD
password - if the
do_restore
key is specified, restores the database in the DBMS either by executing an SQL script or using the standard utilities (depending on the DBMS type) - deletes the files created during the previous steps; if the
do_restore
key is specified, the database dump remains
Configure
According to the principles of the 12-factor application, Ubarec takes settings from environment variables.
Name | Required? | Default value | Description |
---|---|---|---|
UBAREC_ENDPOINT_URL |
No | https://storage.yandexcloud.net |
S3 object storage entry point |
UBAREC_REGION_NAME |
No | ru-central1 |
Region name |
UBAREC_ACCESS_KEY |
Yes | Bucket access key ID | |
UBAREC_SECRET_KEY |
Yes | Bucket secret key | |
UBAREC_BUCKET_NAME |
Yes | Bucket name | |
UBAREC_ZIP_PASSWORD |
No | ZIP password | |
UBAREC_DB_TYPE |
No | mssql |
Database type ('mssql' or 'postgres') |
UBAREC_DB_HOST |
No | localhost |
Database server |
UBAREC_DB_PORT |
No | Database connection port | |
UBAREC_DB_USERNAME |
Yes | User name to connect to the database | |
UBAREC_DB_PASSWORD |
Yes | Password to connect to the database | |
UBAREC_DB_DRIVER |
No | ODBC driver to connect to the database (used for MSSQL) | |
UBAREC_TEMP_PATH |
No | User temporary files storage | Path for storing temporary files |
UBAREC_LOG_PATH |
No | Log storage path | |
UBAREC_DEBUG |
No | False |
Debug mode |
UBAREC_FILENAME_PREFIX |
Нет | {hostname}__{backup_name}__ |
Prefix of file name uploaded to S3 storage |
Backup
ubarec backup --help
TODO: Describe the backup algorithm, startup keys
Restore from backup
ubarec restore --help
TODO: Describe the restore algorithm, startup keys
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
File details
Details for the file ubarec-0.2.2.tar.gz
.
File metadata
- Download URL: ubarec-0.2.2.tar.gz
- Upload date:
- Size: 26.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3c72ac3553e78781c96f521708b2f8b130c247ce30c7ab0bd6db6458a7bc2033 |
|
MD5 | 410b245c0052b43bd04eecd2b6625f7a |
|
BLAKE2b-256 | 0db15e68f0753ffd126773784d5b2aa1d9b57b618ba5637c55f526fe6980a2f9 |
File details
Details for the file ubarec-0.2.2-py3-none-any.whl
.
File metadata
- Download URL: ubarec-0.2.2-py3-none-any.whl
- Upload date:
- Size: 11.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.2 importlib_metadata/4.6.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.61.2 CPython/3.8.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6268b59979902af404e7c6056e46c005fa46b1af0d9683582101a38ae85de7c2 |
|
MD5 | 07780d06e8ef9ae98b222a195ad0a10d |
|
BLAKE2b-256 | 6aeb833f46f1f6ae497ba09ff9d658696bb5f6bfb5e9df796188af674434b902 |