Skip to content
This repository was archived by the owner on May 9, 2023. It is now read-only.

Commit 73fae15

Browse files
authored
v2.0.1 (#439)
* Added new --run-server argument; it will fire up the API server (#437) * Added new version.py file for just a placeholder for getting the exact version from one place (#440) * Added new version.py file for just a placeholder for getting the exact version from one place * getting the version from version.py for the FastAPI doc * Added changes handler for each release (#442) * Added changes handler for each release * added changes file for this branch * Added new change files * Documentation updates * Documentation updates extra * Prepared the HISTORY.md
1 parent bea739a commit 73fae15

40 files changed

Lines changed: 320 additions & 118 deletions

HISTORY.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
## v2.0.1 (2021-05-05)
2+
3+
* Added change handler for each release(so-called HISTORY.md), #442 by @shahriyarr
4+
* Added new version.py file for getting the exact version from one place, #440 by @shahriyarr
5+
* New option --run-server was added to start API server, #437 by @shahriyarr

README.md

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,52 @@ MySQL-AutoXtrabackup
22
====================
33

44
MySQL AutoXtrabackup commandline tool written in Python 3.
5-
The source code fully typed with hints - structured the project mostly similar to awesome [FastAPI](https://fastapi.tiangolo.com/)
5+
The source code fully typed with hints - structured the project mostly similar to
6+
[FastAPI](https://fastapi.tiangolo.com/) and [Pydantic](https://github.com/samuelcolvin/pydantic)
67

78
For community from Azerbaijan MySQL User Community: [Python Azerbaijan Community](https://www.facebook.com/groups/python.az).
89

910
For any question please open an issue here.
1011

12+
What this project is about?
13+
---------------------------
14+
15+
The idea for this tool, came from my hard times after accidentally
16+
deleting the table data.
17+
There was a full backup and 12 incremental backups.
18+
It took me 20 minutes to prepare necessary commands for preparing
19+
backups. If you have compressed + encrypted backups you need also,
20+
decrypt and decompress, which is going to add extra time for preparing
21+
backups. Then I decided to automate this process. In other words,
22+
preparing necessary commands for backup and prepare stage were
23+
automated.
24+
25+
If you think, CLI is not for you. We have experimental feature where you can start API server
26+
and take backups using API call.
27+
28+
```
29+
sudo `which autoxtrabackup` --run-server
30+
INFO: Started server process [30238]
31+
INFO: Waiting for application startup.
32+
app started
33+
INFO: Application startup complete.
34+
INFO: Uvicorn running on http://127.0.0.1:5555 (Press CTRL+C to quit)
35+
```
36+
37+
```
38+
$ curl -X POST http://127.0.0.1:5555/backup
39+
{"result":"Successfully finished the backup process"}
40+
```
41+
42+
For the rest please read the full documentation.
43+
1144
Development:
1245
-------------------
1346

14-
Current major version is 2.0 - so if you want to help, please do changes on this branch and then kindly send PR :)
47+
Current major version is >= 2.0 - so if you want to help, please do changes on this branch and then kindly send PR :)
1548
I also encourage you to upgrade from older version as the code base fully updated.
1649

17-
Read full documentation here(can be outdated):
50+
Read full documentation here:
1851
----------------------------------------------
1952

2053
[**MySQL-AutoXtrabackup documentation!**](https://autoxtrabackup.azepug.az/)

changes/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Pending Changes
2+
3+
This directory contains files describing changes to `mysql-autoxtrabackup` since the last release.
4+
5+
If you're creating a pull request, please add a new file to this directory called
6+
`<pull request or issue id>-<github username>.md`. It should be formatted as a single paragraph of markdown
7+
8+
The contents of this file will be used to update `HISTORY.md` before the next release.

changes/make_history.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/usr/bin/env python3
2+
import re
3+
import sys
4+
from datetime import date
5+
from importlib.machinery import SourceFileLoader
6+
from pathlib import Path
7+
8+
THIS_DIR = Path(__file__).parent
9+
name_regex = re.compile(r'(\d+)-(.*?)\.md')
10+
bullet_list = []
11+
12+
for p in THIS_DIR.glob('*.md'):
13+
if p.name == 'README.md':
14+
continue
15+
m = name_regex.fullmatch(p.name)
16+
if not m:
17+
raise RuntimeError(f'{p.name!r}: invalid change file name')
18+
gh_id, creator = m.groups()
19+
content = p.read_text().replace('\r\n', '\n').strip('\n. ')
20+
if '\n\n' in content:
21+
raise RuntimeError(f'{p.name!r}: content includes multiple paragraphs')
22+
content = content.replace('\n', '\n ')
23+
priority = 0
24+
if '**breaking change' in content.lower():
25+
priority = 2
26+
elif content.startswith('**'):
27+
priority = 1
28+
bullet_list.append((priority, int(gh_id), f'* {content}, #{gh_id} by @{creator}'))
29+
30+
if not bullet_list:
31+
print('no changes found')
32+
sys.exit(0)
33+
34+
version = SourceFileLoader('version', 'mysql_autoxtrabackup/utils/version.py').load_module()
35+
chunk_title = f'v{version.VERSION} ({date.today():%Y-%m-%d})'
36+
new_chunk = '## {}\n\n{}\n\n'.format(chunk_title, '\n'.join(c for *_, c in sorted(bullet_list, reverse=True)))
37+
38+
print(f'{chunk_title}...{len(bullet_list)} items')
39+
history_path = THIS_DIR / '..' / 'HISTORY.md'
40+
history = new_chunk + history_path.read_text()
41+
42+
history_path.write_text(history)
43+
for p in THIS_DIR.glob('*.md'):
44+
if p.name != 'README.md':
45+
p.unlink()
46+
47+
print(
48+
'changes deleted and HISTORY.md successfully updated, to reset use:\n\n'
49+
' git checkout -- changes/*-*.md HISTORY.md\n'
50+
)

docs/advance_features.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ Taking backup:
111111
::
112112

113113

114-
$ autoxtrabackup -v -lf /home/shahriyar.rzaev/autoxtrabackup_2_3_5_6.log -l DEBUG \
114+
$ sudo autoxtrabackup -v -lf /home/shahriyar.rzaev/autoxtrabackup_2_3_5_6.log -l DEBUG \
115115
--defaults-file=/home/shahriyar.rzaev/XB_TEST/server_dir/xb_2_4_ps_5_7.cnf --backup --dry_run
116116

117117

@@ -120,7 +120,7 @@ Preparing backups:
120120
::
121121

122122

123-
$ autoxtrabackup -v -lf /home/shahriyar.rzaev/autoxtrabackup_2_3_5_6.log -l DEBUG \
123+
$ sudo autoxtrabackup -v -lf /home/shahriyar.rzaev/autoxtrabackup_2_3_5_6.log -l DEBUG \
124124
--defaults-file=/home/shahriyar.rzaev/XB_TEST/server_dir/xb_2_4_ps_5_7.cnf --prepare --dry_run
125125

126126

docs/api.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Here is the basic ideas how to use API calls to operate on backups
2+
==================================================================
3+
4+
Currently, we have only 4 endpoints.
5+
6+
.. image:: doc_api.png
7+
:width: 400
8+
:alt: DOC API
9+
10+
11+
Sample cURLs:
12+
-------------
13+
14+
After starting API server:
15+
16+
::
17+
18+
$ sudo `which autoxtrabackup` --run-server
19+
20+
Of course you can use the Web UI for taking backups, but in case you want to send requests,
21+
below I have provided sample cURLs.
22+
23+
Taking backup:
24+
25+
::
26+
27+
$ curl -X POST http://127.0.0.1:5555/backup
28+
{"result":"Successfully finished the backup process"}
29+
30+
Preparing backup:
31+
32+
::
33+
34+
$ curl -X POST http://127.0.0.1:5555/prepare
35+
{"result":"Successfully prepared all the backups"}
36+
37+
Listing backups:
38+
39+
::
40+
41+
$ curl http://127.0.0.1:5555/backups
42+
{"backups":{"full":[{"2021-05-05_18-37-36":"Full-Prepared"}],"inc":["2021-05-05_18-38-19"]}}
43+
44+
45+
Removing backups:
46+
47+
::
48+
49+
$ curl -X DELETE http://127.0.0.1:5555/delete
50+
{"result":"There is no backups or backups removed successfully"}

docs/basic_features.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Backup
66

77
Yes you are right, this tool is for taking backups.
88
It should take care for automating this process for you.
9-
You can specify the backup directory in config file (default /etc/bck.conf) under [Backup] category.
9+
You can specify the backup directory in config file (default ~/.autoxtrabackup/autoxtrabackup.cnf) under [Backup] category.
1010
So you have prepared your config and now you are ready for start.
1111

1212
The command for taking full backup with DEBUG enabled, i.e first run of the tool.
@@ -81,7 +81,7 @@ For now let's choose 1:
8181

8282
::
8383

84-
$ sudo /home/shako/REPOS/MySQL-AutoXtraBackup/.venv/bin/autoxtrabackup --prepare -v -l DEBUG
84+
$ sudo `which autoxtrabackup` --prepare -v -l DEBUG
8585

8686

8787
That's it. Your backup is ready to restore/recovery.

docs/basic_overview.rst

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,15 @@ backups, also for preparing backups, as well as to restore. Here is project path
1010

1111
::
1212

13-
* backup_backup -- Full and Incremental backup taker script.
14-
* backup_prepare -- Backup prepare and restore script.
15-
* general_conf -- All-in-one config file's and config reader class folder.
16-
* process_runner -- The directory for process runner script.
17-
* test -- The directory for test things.
18-
* setup.py -- Setuptools Setup file.
19-
* autoxtrabackup.py -- Commandline Tool provider script.
20-
* VagrantFile -- The Vagrant thing for starting using this tool[will be useful to contributors].
21-
* ~/.autoxtrabackup/autoxtrabackup.cnf -- Config file will be created during setup.
13+
* mysql_autoxtrabackup -- source directory
14+
* mysql_autoxtrabackup/backup_backup -- Full and Incremental backup taker script.
15+
* mysql_autoxtrabackup/backup_prepare -- Backup prepare and restore script.
16+
* mysql_autoxtrabackup/general_conf -- All-in-one config file's and config reader class folder.
17+
* mysql_autoxtrabackup/process_runner -- The directory for process runner script.
18+
* mysql_autoxtrabackup/autoxtrabackup.py -- Commandline Tool provider script.
19+
* mysql_autoxtrabackup/api -- The API server written in FastAPI.
20+
* tests -- The directory for test things.
21+
* ~/.autoxtrabackup/autoxtrabackup.cnf -- Config file will be created during setup.
2222

2323

2424
Available Options
@@ -32,20 +32,24 @@ Available Options
3232
Options:
3333
--dry-run Enable the dry run.
3434
--prepare Prepare/recover backups.
35+
--run-server Start the FastAPI app for serving API
3536
--backup Take full and incremental backups.
3637
--version Version information.
3738
--defaults-file TEXT Read options from the given file [default: /
3839
home/shako/.autoxtrabackup/autoxtrabackup.cn
3940
f]
41+
4042
--tag TEXT Pass the tag string for each backup
4143
--show-tags Show backup tags and exit
4244
-v, --verbose Be verbose (print to console)
4345
-lf, --log-file TEXT Set log file [default: /home/shako/.autoxtr
4446
abackup/autoxtrabackup.log]
47+
4548
-l, --log, --log-level [DEBUG|INFO|WARNING|ERROR|CRITICAL]
4649
Set log level [default: INFO]
4750
--log-file-max-bytes INTEGER Set log file max size in bytes [default:
4851
1073741824]
52+
4953
--log-file-backup-count INTEGER
5054
Set log file backup count [default: 7]
5155
--help Print help message and exit.

0 commit comments

Comments
 (0)