MediaWikiServerTools 0.2.6__tar.gz → 0.3.0__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.
Files changed (34) hide show
  1. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/PKG-INFO +2 -2
  2. mediawikiservertools-0.3.0/mwstools_backend/__init__.py +1 -0
  3. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/cron_backup.py +77 -17
  4. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/sql_backup.py +7 -2
  5. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/tsite.py +119 -31
  6. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/version.py +1 -1
  7. mediawikiservertools-0.2.6/mwstools_backend/__init__.py +0 -1
  8. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/.github/workflows/build.yml +0 -0
  9. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/.github/workflows/upload-to-pypi.yml +0 -0
  10. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/.gitignore +0 -0
  11. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/.project +0 -0
  12. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/.pydevproject +0 -0
  13. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/AGENTS.md +0 -0
  14. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/LICENSE +0 -0
  15. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/README.md +0 -0
  16. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/html_table.py +0 -0
  17. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/remote.py +0 -0
  18. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/server.py +0 -0
  19. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/site.py +0 -0
  20. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/webscrape.py +0 -0
  21. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/mwstools_backend/wikibackup.py +0 -0
  22. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/pyproject.toml +0 -0
  23. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/scripts/blackisort +0 -0
  24. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/scripts/doc +0 -0
  25. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/scripts/install +0 -0
  26. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/scripts/release +0 -0
  27. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/scripts/test +0 -0
  28. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/tests/__init__.py +0 -0
  29. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/tests/smw_access.py +0 -0
  30. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/tests/test_remote.py +0 -0
  31. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/tests/test_server.py +0 -0
  32. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/tests/test_site.py +0 -0
  33. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/tests/test_sqlbackup.py +0 -0
  34. {mediawikiservertools-0.2.6 → mediawikiservertools-0.3.0}/tests/test_wikibackup.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.5
2
2
  Name: MediaWikiServerTools
3
- Version: 0.2.6
3
+ Version: 0.3.0
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.3.0"
@@ -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 path [default: %(default)s]",
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
- # the database container running the mysql instance
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.backup_dir),
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
- archive_path = self.backup_dir / archive_name
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
- result = self.shell.run(cmd, text=True, debug=self.debug, tee=self.verbose)
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
- mysql_root_cmd = self.args.mysql_root_cmd
269
- if mysql_root_cmd is None:
270
- # Default: use mysqlr wrapper with container
271
- mysql_root_cmd = f"mysqlr --no-tty -cn {self.container}"
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
- mysqldump_cmd = self.args.mysqldump_cmd
274
- if mysqldump_cmd is None:
275
- mysqldump_cmd = f"mysqlr --no-tty -cn {self.container} --dump"
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="backup",
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.1.1"
438
+ version = "0.2.7"
379
439
  description = (
380
440
  "Database backup with expiration management to be started from cron"
381
441
  )
382
- updated = "2025-12-23"
383
- doc_url = "https://github.com/WolfgangFahl/pyWikiCMS"
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
- self.remote = Remote(host=backup_host)
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
  }
@@ -21,7 +21,6 @@ from typing import Dict, Iterable, Iterator, List, TypeVar
21
21
  from basemkit.base_cmd import BaseCmd
22
22
  from basemkit.persistent_log import Log
23
23
  from basemkit.profiler import Profiler
24
- from mwstools_backend.version import Version
25
24
  from tqdm import tqdm
26
25
  from wikibot3rd.smw import SMWClient
27
26
  from wikibot3rd.wikiclient import WikiClient
@@ -31,6 +30,7 @@ from mwstools_backend.remote import Remote, RunConfig
31
30
  from mwstools_backend.server import Server, Servers
32
31
  from mwstools_backend.site import Site, WikiSite
33
32
  from mwstools_backend.sql_backup import SqlBackup
33
+ from mwstools_backend.version import Version
34
34
 
35
35
  # enable generic types
36
36
  T = TypeVar("T")
@@ -69,7 +69,7 @@ class TransferTask:
69
69
  def __post_init__(self):
70
70
  self.force = self.args.force
71
71
  self.update = self.args.update
72
- self.debug=self.args.debug
72
+ self.debug = self.args.debug
73
73
  self.timeout = self.args.timeout
74
74
  self.use_git = self.args.git
75
75
  self.wikiUser = WikiUser.ofWikiId(self.wiki_site.wikiId, lenient=True)
@@ -217,7 +217,9 @@ class TransferTask:
217
217
  return False
218
218
  rsync_prof.time(f" {self.wiki_site.hostname}")
219
219
  result = True
220
- if self.use_git:
220
+ if self.args.backup:
221
+ result = self.adapt_backup_server(site_path)
222
+ if result and self.use_git:
221
223
  git_prof = Profiler("git commit", profile=self.args.profile)
222
224
  proc = self.git_target(target_path=site_path)
223
225
  if proc.returncode == 0:
@@ -226,6 +228,47 @@ class TransferTask:
226
228
  result = False
227
229
  return result
228
230
 
231
+ def backup_server_name(self) -> str:
232
+ """
233
+ the hostname of a backup copy: the --alias if given
234
+ else <name>-<target hostname>
235
+ """
236
+ alias = getattr(self.args, "alias", None)
237
+ if alias:
238
+ server_name = alias
239
+ else:
240
+ server_name = f"{self.wiki_site.name}-{self.target.hostname}"
241
+ return server_name
242
+
243
+ def adapt_backup_server(self, site_path: str) -> bool:
244
+ """
245
+ set $wgServer of the backup copy to its own name -
246
+ the only target-local setting of a copy (#18)
247
+
248
+ Args:
249
+ site_path: the site directory on the target
250
+
251
+ Returns:
252
+ True if the setting is in place
253
+ """
254
+ server_name = self.backup_server_name()
255
+ settings_path = f"{site_path}/LocalSettings.php"
256
+ wg_server = f"https://{server_name}"
257
+ sed_cmd = (
258
+ "sed -i -E "
259
+ f"'s#^([[:space:]]*[$]wgServer[[:space:]]*=[[:space:]]*).*$#\\1\"{wg_server}\";#' "
260
+ f"{settings_path}"
261
+ )
262
+ # base64 transport avoids quoting through the local and the ssh shell
263
+ b64 = base64.b64encode(sed_cmd.encode()).decode()
264
+ proc = self.target.remote.run(f"printf %s {b64!r} | base64 -d | sudo bash")
265
+ lines = self.target.remote.readlines(settings_path) or []
266
+ actual = WikiSite.getVarFromSettings("wgServer", lines)
267
+ ok = proc.returncode == 0 and actual == wg_server
268
+ marker = "✅" if ok else "❌"
269
+ print(f"{marker} $wgServer of the copy {settings_path}: {actual}")
270
+ return ok
271
+
229
272
  def get_wiki_sql(self):
230
273
  wiki = self.wiki_site
231
274
  wiki.configure_of_settings()
@@ -258,11 +301,15 @@ class TransferTask:
258
301
  remote_cmd = f"printf %s {b64!r} | base64 -d | {mysql_cmd}"
259
302
  proc = self.target.remote.run(remote_cmd)
260
303
  success = proc.returncode == 0
304
+ # never show the grant statement, it carries the db password
305
+ shown = name if name == "grant" else sql_cmd
261
306
  if success:
262
- print(f"✅ {sql_cmd}:{proc.stdout}")
307
+ lines = proc.stdout.splitlines()
308
+ summary = proc.stdout if len(lines) <= 3 else f"{len(lines)} lines"
309
+ print(f"✅ {shown}:{summary}")
263
310
  sql_results[name] = proc.stdout
264
311
  else:
265
- print(f"❌ {sql_cmd}:{proc.stderr}")
312
+ print(f"❌ {shown}:{proc.stderr}")
266
313
  break
267
314
  return sql_results
268
315
 
@@ -283,11 +330,15 @@ class TransferTask:
283
330
  ("show_tables", "SHOW TABLES", database),
284
331
  ]
285
332
  sql_results = self.run_sql_cmds(sql_cmds)
333
+ do_restore = False
286
334
  # ping means the database is accessible
287
335
  if "ping" in sql_results:
288
336
  result = True
337
+ # an existing database is refreshed only on --update (#16)
338
+ if "show_tables" in sql_results:
339
+ do_restore = bool(self.args.update)
289
340
  # if show_tables fails the database does not exist
290
- if "show_tables" not in sql_results:
341
+ else:
291
342
  # (name, sql, database)
292
343
  sql_cmds = [
293
344
  ("create_db", f"CREATE DATABASE IF NOT EXISTS `{database}`", None),
@@ -305,25 +356,21 @@ class TransferTask:
305
356
  ]
306
357
  sql_results = self.run_sql_cmds(sql_cmds)
307
358
  # restore if update flag is set or no rev_count
308
- do_restore = (
309
- result and self.args.update or "rev_count" not in sql_results
359
+ do_restore = bool(self.args.update) or "rev_count" not in sql_results
360
+ if do_restore:
361
+ restore_cmd = f"pv {self.target_backup_path} | {mysqlr} -D {database}"
362
+ # honor the user supplied --timeout for the (potentially long)
363
+ # SQL restore instead of the 10s RunConfig default (closes #6)
364
+ restore_run_config = RunConfig(timeout=self.timeout)
365
+ proc = self.target.remote.run(
366
+ restore_cmd, run_config=restore_run_config
310
367
  )
311
- if do_restore:
312
- restore_cmd = (
313
- f"pv {self.target_backup_path} | {mysqlr} -D {database}"
314
- )
315
- # honor the user supplied --timeout for the (potentially long)
316
- # SQL restore instead of the 10s RunConfig default (closes #6)
317
- restore_run_config = RunConfig(timeout=self.timeout)
318
- proc = self.target.remote.run(
319
- restore_cmd, run_config=restore_run_config
320
- )
321
- success = proc.returncode == 0
322
- result = result and success
323
- if success:
324
- print(f"✅ restore:{proc.stdout}")
325
- else:
326
- print(f"❌ restore:{proc.stderr}")
368
+ success = proc.returncode == 0
369
+ result = result and success
370
+ if success:
371
+ print(f"✅ restore {self.target_backup_path} into {database}")
372
+ else:
373
+ print(f"❌ restore:{proc.stderr}")
327
374
  if result:
328
375
  sql_cmds = [
329
376
  ("user_count", "SELECT COUNT(*) AS user_count FROM user;", database),
@@ -362,7 +409,8 @@ class TransferTask:
362
409
  print("❌ Backup creation failed or still outdated.")
363
410
  return False
364
411
 
365
- if target_age:
412
+ age_diff_secs = 0
413
+ if target_age is not None:
366
414
  age_diff_secs = (target_age - source_age) * 86400
367
415
  # more than 1 minute difference
368
416
  if target_age is None or age_diff_secs > 60:
@@ -379,7 +427,8 @@ class TransferTask:
379
427
  "chgrp": f"sudo chgrp {self.target.remote.gid} {self.target_base_path}",
380
428
  }
381
429
  )
382
- run_config = RunConfig(force_local=True, ignore_container=True)
430
+ # pull on the target server, not on the local machine (#17)
431
+ run_config = RunConfig(timeout=self.timeout, ignore_container=True)
383
432
  scp_cmd = f"scp -p {source_path} {target_path}"
384
433
  proc = self.target.remote.run(scp_cmd, run_config=run_config)
385
434
  result = proc.returncode == 0
@@ -450,7 +499,7 @@ class TransferTask:
450
499
  result = False
451
500
  server_name = f"{self.wiki_site.hostname}"
452
501
  if self.args.backup:
453
- server_name = f"{self.wiki_site.name}-{self.target.hostname}"
502
+ server_name = self.backup_server_name()
454
503
  self.target.probe_apache_configs()
455
504
  # first check the configuration
456
505
  config_path = self.target.apache_configs.get(server_name)
@@ -530,19 +579,46 @@ class TransferSite:
530
579
  for filepath in files:
531
580
  Checks.check_age(server.remote, filepath, 1.0)
532
581
 
582
+ def check_backup(self):
583
+ """
584
+ check the backup state of the selected wikis:
585
+ the age of the full SQL dump of each selected wiki
586
+ on each selected server (#12)
587
+ """
588
+ servers = self.get_selected_servers_list()
589
+ for wiki in self.get_selected_wikis():
590
+ for server in servers:
591
+ filepath = f"{server.sql_backup_path}/today/{wiki.database}_full.sql"
592
+ age = Checks.check_age(server.remote, filepath, 1.0)
593
+ if age is None:
594
+ print(f"{server.remote.host}:{filepath} ❌ missing")
595
+
533
596
  def check_database(self):
534
597
  """
535
598
  check the database access
536
599
  """
537
600
  index = 0
601
+ target_server = self.servers.servers.get(self.target) if self.target else None
538
602
  for wiki in self.get_selected_wikis():
539
603
  if wiki.localSettings is None:
540
604
  wiki.configure_of_settings()
605
+ index += 1
606
+ print(
607
+ f"{index:2d}:{wiki.hostname} {wiki.localSettings}: {wiki.database} vs {wiki.database_setting} dbUser:{wiki.dbUser}"
608
+ )
609
+ # the copy of the wiki on the target uses the same site directory (#14)
610
+ if target_server is not None and target_server.sitedir:
611
+ settings_path = (
612
+ f"{target_server.sitedir}/{wiki.hostname}/LocalSettings.php"
613
+ )
614
+ lines = target_server.remote.readlines(settings_path) or []
615
+ copy_db = WikiSite.getVarFromSettings("wgDBname", lines)
616
+ copy_user = WikiSite.getVarFromSettings("wgDBuser", lines)
617
+ copy_server = WikiSite.getVarFromSettings("wgServer", lines)
541
618
  index += 1
542
619
  print(
543
- f"{index:2d}:{wiki.database} vs {wiki.database_setting} dbUser:{wiki.dbUser}"
620
+ f"{index:2d}:{copy_server} {target_server.hostname}:{settings_path}: {copy_db} dbUser:{copy_user}"
544
621
  )
545
- pass
546
622
 
547
623
  def check_endpoints(self):
548
624
  """
@@ -562,6 +638,16 @@ class TransferSite:
562
638
  for wiki in self.get_selected_wikis():
563
639
  index += 1
564
640
  self.check_remote(wiki.remote, index)
641
+ # the selected servers and the copy site named by --alias (#14)
642
+ for server in self.get_selected_servers():
643
+ index += 1
644
+ self.check_remote(server.remote, index)
645
+ if self.args.alias:
646
+ index += 1
647
+ alias_site = Site(self.args.alias)
648
+ proc = alias_site.ping()
649
+ ok = Site.state_symbol(proc.returncode == 0)
650
+ print(f"{index:02d}:{self.args.alias:<26} {ok}")
565
651
 
566
652
  def get_wiki_user(self, wikisite: WikiSite, purpose: str):
567
653
  """
@@ -618,7 +704,9 @@ class TransferSite:
618
704
  "php": "php -v",
619
705
  }
620
706
  remote.log.do_log = self.args.debug
621
- procs = remote.run_cmds(cmds, stop_on_error=False)
707
+ # continue after a failing command so every component is reported (#13)
708
+ run_config = RunConfig(stop_on_error=False, do_log=self.args.debug)
709
+ procs = remote.run_cmds(cmds, run_config=run_config)
622
710
  results = {}
623
711
  for key, proc in procs.items():
624
712
  if proc.returncode == 0:
@@ -1006,7 +1094,7 @@ class TransferSiteCmd(BaseCmd):
1006
1094
  handled = True
1007
1095
  if args.check_database:
1008
1096
  tsite.check_database()
1009
- handlet = True
1097
+ handled = True
1010
1098
  if args.check_endpoints:
1011
1099
  tsite.check_endpoints()
1012
1100
  handled = True
@@ -18,7 +18,7 @@ class Version(object):
18
18
  description = "MediaWiki Server Management System - Apache Site management, SQL backups, cron-based backups "
19
19
  version = mwstools_backend.__version__
20
20
  date = "2022-11-16"
21
- updated = "2026-06-10"
21
+ updated = "2026-11-24"
22
22
  authors = "Wolfgang Fahl"
23
23
  doc_url = "https://wiki.bitplan.com/index.php/MediaWikiServerTools"
24
24
  chat_url = "https://github.com/WolfgangFahl/MediaWikiServerTools/discussions"
@@ -1 +0,0 @@
1
- __version__ = "0.2.6"