Compare commits

..

2 commits

Author SHA1 Message Date
68496774b6
Migrate Stump to Podman 2024-10-15 09:41:51 +02:00
4c26d55c14
[ansible] I forgor 2024-10-15 09:39:23 +02:00
4 changed files with 46 additions and 12 deletions

View file

@ -63,13 +63,7 @@ projects:
projects_to_backup:
- etebase
- hedgedoc
- keycloak
- mailserver
- postgres
- stump
- synapse
- uptime-kuma

View file

@ -12,6 +12,7 @@ import yaml
def backupProj(project):
database = None
paths = []
sqlite_db = None
if project == 'postgres':
database = 'all'
@ -22,22 +23,25 @@ def backupProj(project):
for path in env['backup'][project]:
paths += [path]
if database is not None or len(paths) > 0:
if project in env['backup_sqlite'].keys():
sqlite_db = env['backup_sqlite'][project]
if database is not None or sqlite_db is not None or len(paths) > 0:
print(f"Running backup for project {project}.")
if len(paths) == 0:
borgCreate(project, database=database)
borgCreate(project, database=database, sqlite_db=sqlite_db)
else:
borgCreate(project, path=paths[0], database=database)
borgCreate(project, path=paths[0], database=database, sqlite_db=sqlite_db)
for path in paths[1:]:
archiveName = re.sub('/', '-', path)
borgCreate(f"{project}-{archiveName}", path=path)
def borgCreate(name, path=None, database=None):
if path is None and database is None:
print(f"Cannot create backup, you must pass at least one parameter amongst: path, database (archive name = {name}).", file=sys.stderr)
def borgCreate(name, path=None, database=None, sqlite_db=None):
if path is None and database is None and sqlite_db is None:
print(f"Cannot create backup, you must pass at least one parameter amongst: path, database, database_path (archive name = {name}).", file=sys.stderr)
return 1
borgPaths = []
@ -68,6 +72,22 @@ def borgCreate(name, path=None, database=None):
borgInput = dumpProc.stdout
if sqlite_db is not None:
print(f"Dumping SQLite database {sqlite_db}.")
sqlite_args = ["podman", "run", "--rm", "-v", f"{sqlite_db}:/db.sqlite", "docker.io/library/alpine:latest", "sh", "-c", "apk add sqlite &>/dev/null; sqlite3 /db.sqlite .dump"]
dumpProc = subprocess.run(sqlite_args, capture_output=True, text=True)
if dumpProc.returncode != 0:
print(f"Failed to dump SQLite database {sqlite_db}.", file=sys.stderr)
return 1
database = Path(sqlite_db).stem
borgPaths += ["-", "--stdin-name", f"{database}.sqlite"]
borgInput = dumpProc.stdout
if path is None:
print(f"Creating archive '{name}' from database {database}.")
elif database is None:

View file

@ -0,0 +1,14 @@
services:
stump:
container_name: stump
image: docker.io/aaronleopold/stump:0.0.7
network_mode: pasta:-a,${env['pasta']['stump']['ipv4']},-a,${env['pasta']['stump']['ipv6']}
restart: always
environment:
- PUID=${env['users']['stump']}
- PGID=${env['users']['stump']}
ports:
- 127.0.0.1:${env['ports']['stump']}:10801
volumes:
- ${env['volumes']['stump']['configdir']}:/config
- ${env['volumes']['stump']['datadir']}:/data

View file

@ -32,6 +32,9 @@ backup:
vaultwarden:
- /mnt/vwdata/attachments
backup_sqlite:
stump: /mnt/stump/config/stump.db
borg_repo: /mnt/storagebox/backups/borg2
borg_prune_opts:
- "--keep-within=1d"
@ -66,6 +69,9 @@ pasta:
postgres:
ipv4: 10.86.16.1
ipv6: fc86::16
stump:
ipv4: 10.86.18.1
ipv6: fc86::18
synapse:
ipv4: 10.86.19.1
ipv6: fc86::19