work around nasty characters as part of the database password

This commit is contained in:
Thies Lennart Alff 2025-01-03 21:12:43 +01:00
parent c313b6fdb1
commit b272acf292
Signed by: lennartalff
GPG key ID: 4EC67D34D594104D
2 changed files with 6 additions and 6 deletions

View file

@ -9,8 +9,6 @@
"TIME_FORMAT": "utcnow:%Y-%m-%d_%H:%M:%S", "TIME_FORMAT": "utcnow:%Y-%m-%d_%H:%M:%S",
"REPO_SUBDIR": "forgejo", "REPO_SUBDIR": "forgejo",
"MYSQL_DB": "database name", "MYSQL_DB": "database name",
"MYSQL_USER": "database user required for dumping the database",
"MYSQL_PASSWORD": "password required for dumping the database "
}, },
"remotes": [ "remotes": [
{ {

View file

@ -55,11 +55,13 @@ class ForgejoManager(backup_manager.BackupManager):
return True return True
def dump_database(self): def dump_database(self):
password = self._common["MYSQL_PASSWORD"]
user = self._common["MYSQL_USER"]
db = self._common["MYSQL_DB"] db = self._common["MYSQL_DB"]
# we assume that a [client] conf as default for user and password is mounted inside the mysql directory of the container
cmd = f"docker compose exec -i --user 1000:1000 db mariadb-dump --single-transaction --default-character-set=utf8mb4 -h localhost -u {user} --password={password} {db} > mysql/forgejo.sql" # e.g.:
# [client]
# user=<theusername>
# password=<thepassword>
cmd = f"docker compose exec -it db sh -c 'mariadb-dump --defaults-extra-file=/var/lib/mysql/forgejo-mysql.conf {db} > /var/lib/mysql/forgejo.sql'"
try: try:
result = subprocess.run( result = subprocess.run(
cmd, cmd,