MediaWikiServerTools 0.2.6__tar.gz → 0.2.7__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/PKG-INFO +2 -2
- mediawikiservertools-0.2.7/mwstools_backend/__init__.py +1 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/cron_backup.py +77 -17
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/sql_backup.py +7 -2
- mediawikiservertools-0.2.6/mwstools_backend/__init__.py +0 -1
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/.github/workflows/build.yml +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/.github/workflows/upload-to-pypi.yml +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/.gitignore +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/.project +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/.pydevproject +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/AGENTS.md +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/LICENSE +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/README.md +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/html_table.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/remote.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/server.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/site.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/tsite.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/version.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/webscrape.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/mwstools_backend/wikibackup.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/pyproject.toml +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/scripts/blackisort +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/scripts/doc +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/scripts/install +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/scripts/release +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/scripts/test +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/tests/__init__.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/tests/smw_access.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/tests/test_remote.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/tests/test_server.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/tests/test_site.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/tests/test_sqlbackup.py +0 -0
- {mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/tests/test_wikibackup.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
2
|
Name: MediaWikiServerTools
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.7
|
|
4
4
|
Summary: MediaWikiServerTools: MediaWiki Server Management System
|
|
5
5
|
Project-URL: Home, https://github.com/BITPlan/MediaWikiServerTools
|
|
6
6
|
Project-URL: Source, https://github.com/BITPlan/MediaWikiServerTools
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.2.7"
|
|
@@ -32,6 +32,7 @@ class CronBackup(BaseCmd):
|
|
|
32
32
|
"""
|
|
33
33
|
super().__init__(version)
|
|
34
34
|
self.backup_dir = None
|
|
35
|
+
self.archive_dir = None
|
|
35
36
|
self.log_file = None
|
|
36
37
|
self.container = None
|
|
37
38
|
self.full_backup = False
|
|
@@ -71,7 +72,13 @@ class CronBackup(BaseCmd):
|
|
|
71
72
|
parser.add_argument(
|
|
72
73
|
"--backup-dir",
|
|
73
74
|
default="/var/backup/sqlbackup",
|
|
74
|
-
help="backup directory
|
|
75
|
+
help="local backup directory (today/ + tmp/ dumps) [default: %(default)s]",
|
|
76
|
+
)
|
|
77
|
+
parser.add_argument(
|
|
78
|
+
"--archive-dir",
|
|
79
|
+
default=None,
|
|
80
|
+
help="directory for the dated .tgz archive + expiration; may be a "
|
|
81
|
+
"remote/mounted path (defaults to --backup-dir)",
|
|
75
82
|
)
|
|
76
83
|
parser.add_argument(
|
|
77
84
|
"--log-file",
|
|
@@ -79,7 +86,24 @@ class CronBackup(BaseCmd):
|
|
|
79
86
|
help="log file path [default: %(default)s]",
|
|
80
87
|
)
|
|
81
88
|
# database settings
|
|
82
|
-
#
|
|
89
|
+
# backend selection: native client vs docker container
|
|
90
|
+
parser.add_argument(
|
|
91
|
+
"--native",
|
|
92
|
+
action="store_true",
|
|
93
|
+
help="use the native MySQL/MariaDB client (sudo mysql / sudo mysqldump -u root) "
|
|
94
|
+
"instead of a docker container",
|
|
95
|
+
)
|
|
96
|
+
parser.add_argument(
|
|
97
|
+
"--docker",
|
|
98
|
+
metavar="CN",
|
|
99
|
+
help="use the docker container CN (via the mysqlr wrapper) for MySQL access",
|
|
100
|
+
)
|
|
101
|
+
parser.add_argument(
|
|
102
|
+
"--backup-user",
|
|
103
|
+
default="backup",
|
|
104
|
+
help="OS user that owns the backup files [default: %(default)s]",
|
|
105
|
+
)
|
|
106
|
+
# the database container running the mysql instance (legacy; prefer --docker CN)
|
|
83
107
|
parser.add_argument(
|
|
84
108
|
"--container",
|
|
85
109
|
default="family-db",
|
|
@@ -125,6 +149,14 @@ class CronBackup(BaseCmd):
|
|
|
125
149
|
help="number of yearly backups to keep [default: %(default)s]",
|
|
126
150
|
)
|
|
127
151
|
|
|
152
|
+
# per-command timeout for the dumps (large DBs need far more than 10s)
|
|
153
|
+
parser.add_argument(
|
|
154
|
+
"--timeout",
|
|
155
|
+
type=float,
|
|
156
|
+
default=3600,
|
|
157
|
+
help="timeout in seconds for each SQL dump/command [default: %(default)s]",
|
|
158
|
+
)
|
|
159
|
+
|
|
128
160
|
# Shell configuration
|
|
129
161
|
parser.add_argument(
|
|
130
162
|
"--profile", help="shell profile to source (e.g., ~/.zprofile)"
|
|
@@ -173,7 +205,7 @@ class CronBackup(BaseCmd):
|
|
|
173
205
|
)
|
|
174
206
|
|
|
175
207
|
expire_backups = ExpireBackups(
|
|
176
|
-
rootPath=str(self.
|
|
208
|
+
rootPath=str(self.archive_dir),
|
|
177
209
|
baseName="sql_backup",
|
|
178
210
|
ext=".tgz",
|
|
179
211
|
expiration=expiration,
|
|
@@ -186,6 +218,7 @@ class CronBackup(BaseCmd):
|
|
|
186
218
|
self.log("Expiration rules completed")
|
|
187
219
|
|
|
188
220
|
except Exception as ex:
|
|
221
|
+
self.log(f"ERROR: {type(ex).__name__}: {ex}")
|
|
189
222
|
self.handle_exception(ex)
|
|
190
223
|
exit_code = 1
|
|
191
224
|
|
|
@@ -201,7 +234,8 @@ class CronBackup(BaseCmd):
|
|
|
201
234
|
exit_code = 1
|
|
202
235
|
date_str = datetime.now().strftime("%Y-%m-%d")
|
|
203
236
|
archive_name = f"sql_backup.{date_str}.tgz"
|
|
204
|
-
|
|
237
|
+
self.archive_dir.mkdir(parents=True, exist_ok=True)
|
|
238
|
+
archive_path = self.archive_dir / archive_name
|
|
205
239
|
|
|
206
240
|
self.log(f"Creating archive {archive_name}...")
|
|
207
241
|
|
|
@@ -234,7 +268,15 @@ class CronBackup(BaseCmd):
|
|
|
234
268
|
)
|
|
235
269
|
|
|
236
270
|
cmd = " ".join(cmd_parts)
|
|
237
|
-
|
|
271
|
+
# honour --timeout: the basemkit Shell.run default of 60 s truncates
|
|
272
|
+
# large archives (see issue #11 / the qn 2026-07-01 incident)
|
|
273
|
+
result = self.shell.run(
|
|
274
|
+
cmd,
|
|
275
|
+
text=True,
|
|
276
|
+
debug=self.debug,
|
|
277
|
+
tee=self.verbose,
|
|
278
|
+
timeout=self.args.timeout,
|
|
279
|
+
)
|
|
238
280
|
|
|
239
281
|
if result.returncode == 0:
|
|
240
282
|
self.log(f"Archive {archive_name} created successfully")
|
|
@@ -245,6 +287,7 @@ class CronBackup(BaseCmd):
|
|
|
245
287
|
exit_code = 1
|
|
246
288
|
|
|
247
289
|
except Exception as ex:
|
|
290
|
+
self.log(f"ERROR: {type(ex).__name__}: {ex}")
|
|
248
291
|
self.handle_exception(ex)
|
|
249
292
|
exit_code = 1
|
|
250
293
|
|
|
@@ -264,19 +307,26 @@ class CronBackup(BaseCmd):
|
|
|
264
307
|
# Ensure backup directory exists
|
|
265
308
|
self.backup_dir.mkdir(parents=True, exist_ok=True)
|
|
266
309
|
|
|
267
|
-
# Construct MySQL commands
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
310
|
+
# Construct MySQL commands.
|
|
311
|
+
# Explicit --mysql-root-cmd / --mysqldump-cmd always win; otherwise the
|
|
312
|
+
# backend is chosen by --native (native client) vs docker container
|
|
313
|
+
# (--docker CN, falling back to the legacy --container default).
|
|
314
|
+
if self.args.native:
|
|
315
|
+
default_root_cmd = "sudo mysql"
|
|
316
|
+
default_dump_cmd = "sudo mysqldump -u root"
|
|
317
|
+
else:
|
|
318
|
+
cn = self.args.docker or self.container
|
|
319
|
+
default_root_cmd = f"mysqlr --no-tty -cn {cn}"
|
|
320
|
+
default_dump_cmd = f"mysqlr --no-tty -cn {cn} --dump"
|
|
272
321
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
322
|
+
mysql_root_cmd = self.args.mysql_root_cmd or default_root_cmd
|
|
323
|
+
mysqldump_cmd = self.args.mysqldump_cmd or default_dump_cmd
|
|
324
|
+
self.log(f"MySQL root cmd: {mysql_root_cmd}")
|
|
325
|
+
self.log(f"mysqldump cmd: {mysqldump_cmd}")
|
|
276
326
|
|
|
277
327
|
# Create SqlBackup instance
|
|
278
328
|
sql_backup = SqlBackup(
|
|
279
|
-
backup_user=
|
|
329
|
+
backup_user=self.args.backup_user,
|
|
280
330
|
backup_host="localhost",
|
|
281
331
|
backup_dir=str(self.backup_dir),
|
|
282
332
|
mysql_root_script=mysql_root_cmd,
|
|
@@ -284,6 +334,7 @@ class CronBackup(BaseCmd):
|
|
|
284
334
|
verbose=self.verbose,
|
|
285
335
|
debug=self.debug,
|
|
286
336
|
progress=self.args.progress,
|
|
337
|
+
timeout=self.args.timeout,
|
|
287
338
|
)
|
|
288
339
|
|
|
289
340
|
# Initialize if needed
|
|
@@ -303,6 +354,7 @@ class CronBackup(BaseCmd):
|
|
|
303
354
|
exit_code = 1
|
|
304
355
|
|
|
305
356
|
except Exception as ex:
|
|
357
|
+
self.log(f"ERROR: {type(ex).__name__}: {ex}")
|
|
306
358
|
self.handle_exception(ex)
|
|
307
359
|
exit_code = 1
|
|
308
360
|
|
|
@@ -330,6 +382,9 @@ class CronBackup(BaseCmd):
|
|
|
330
382
|
|
|
331
383
|
# Store configuration
|
|
332
384
|
self.backup_dir = Path(args.backup_dir)
|
|
385
|
+
self.archive_dir = (
|
|
386
|
+
Path(args.archive_dir) if args.archive_dir else self.backup_dir
|
|
387
|
+
)
|
|
333
388
|
self.log_file = Path(args.log_file)
|
|
334
389
|
self.container = args.container
|
|
335
390
|
self.full_backup = args.full
|
|
@@ -357,6 +412,11 @@ class CronBackup(BaseCmd):
|
|
|
357
412
|
self.exit_code = result
|
|
358
413
|
|
|
359
414
|
handled = True
|
|
415
|
+
# BaseCmd.run() never reads self.exit_code and would exit 0 even
|
|
416
|
+
# after a failed backup (issue #11) — propagate via SystemExit,
|
|
417
|
+
# which BaseCmd.handle_exception maps to the process exit code.
|
|
418
|
+
if self.exit_code != 0:
|
|
419
|
+
raise SystemExit(self.exit_code)
|
|
360
420
|
|
|
361
421
|
return handled
|
|
362
422
|
|
|
@@ -375,12 +435,12 @@ def main(argv=None):
|
|
|
375
435
|
# Create a version object
|
|
376
436
|
class Version:
|
|
377
437
|
name = "CronBackup"
|
|
378
|
-
version = "0.
|
|
438
|
+
version = "0.2.7"
|
|
379
439
|
description = (
|
|
380
440
|
"Database backup with expiration management to be started from cron"
|
|
381
441
|
)
|
|
382
|
-
updated = "
|
|
383
|
-
doc_url = "https://github.com/WolfgangFahl/
|
|
442
|
+
updated = "2026-07-05"
|
|
443
|
+
doc_url = "https://github.com/WolfgangFahl/MediaWikiServerTools"
|
|
384
444
|
|
|
385
445
|
exit_code = CronBackup.main(Version(), argv)
|
|
386
446
|
return exit_code
|
|
@@ -16,7 +16,7 @@ from typing import List
|
|
|
16
16
|
from basemkit.persistent_log import Log
|
|
17
17
|
from tqdm import tqdm
|
|
18
18
|
|
|
19
|
-
from mwstools_backend.remote import Remote
|
|
19
|
+
from mwstools_backend.remote import Remote, RunConfig
|
|
20
20
|
|
|
21
21
|
|
|
22
22
|
class SqlBackup:
|
|
@@ -34,6 +34,7 @@ class SqlBackup:
|
|
|
34
34
|
verbose: bool = False,
|
|
35
35
|
debug: bool = False,
|
|
36
36
|
progress: bool = False,
|
|
37
|
+
timeout: float = 3600,
|
|
37
38
|
):
|
|
38
39
|
"""
|
|
39
40
|
Initialize SQLBackup instance
|
|
@@ -57,7 +58,10 @@ class SqlBackup:
|
|
|
57
58
|
self.verbose = verbose
|
|
58
59
|
self.debug = debug
|
|
59
60
|
self.progress = progress
|
|
60
|
-
|
|
61
|
+
# SQL dumps of large DBs need far more than the RunConfig 10s default;
|
|
62
|
+
# honour a configurable timeout on every remote command (default 1h).
|
|
63
|
+
self.timeout = timeout
|
|
64
|
+
self.remote = Remote(host=backup_host, run_config=RunConfig(timeout=timeout))
|
|
61
65
|
self.today_dir = self.backup_dir / "today"
|
|
62
66
|
self.tmp_dir = self.backup_dir / "tmp"
|
|
63
67
|
|
|
@@ -313,6 +317,7 @@ class SqlBackup:
|
|
|
313
317
|
"""
|
|
314
318
|
cmds = {
|
|
315
319
|
"create temp dir": f"sudo mkdir -p {self.tmp_dir}",
|
|
320
|
+
"create today dir": f"sudo mkdir -p {self.today_dir}",
|
|
316
321
|
"change permissions": f"sudo chmod 777 {self.tmp_dir}",
|
|
317
322
|
"change owner": f"sudo chown {self.backup_user} {self.tmp_dir}",
|
|
318
323
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.2.6"
|
|
File without changes
|
{mediawikiservertools-0.2.6 → mediawikiservertools-0.2.7}/.github/workflows/upload-to-pypi.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|