Compare commits
No commits in common. "68496774b6df85487c6e377805addf450e083b4c" and "eac272da724843c54b38b30066eb479b9fc8d456" have entirely different histories.
68496774b6
...
eac272da72
4 changed files with 12 additions and 46 deletions
6
env.yml
6
env.yml
|
@ -63,7 +63,13 @@ projects:
|
||||||
|
|
||||||
|
|
||||||
projects_to_backup:
|
projects_to_backup:
|
||||||
|
- etebase
|
||||||
|
- hedgedoc
|
||||||
- keycloak
|
- keycloak
|
||||||
|
- mailserver
|
||||||
|
- postgres
|
||||||
|
- stump
|
||||||
|
- synapse
|
||||||
- uptime-kuma
|
- uptime-kuma
|
||||||
|
|
||||||
|
|
||||||
|
|
32
manage.py
32
manage.py
|
@ -12,7 +12,6 @@ import yaml
|
||||||
def backupProj(project):
|
def backupProj(project):
|
||||||
database = None
|
database = None
|
||||||
paths = []
|
paths = []
|
||||||
sqlite_db = None
|
|
||||||
|
|
||||||
if project == 'postgres':
|
if project == 'postgres':
|
||||||
database = 'all'
|
database = 'all'
|
||||||
|
@ -23,25 +22,22 @@ def backupProj(project):
|
||||||
for path in env['backup'][project]:
|
for path in env['backup'][project]:
|
||||||
paths += [path]
|
paths += [path]
|
||||||
|
|
||||||
if project in env['backup_sqlite'].keys():
|
if database is not None or len(paths) > 0:
|
||||||
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}.")
|
print(f"Running backup for project {project}.")
|
||||||
|
|
||||||
if len(paths) == 0:
|
if len(paths) == 0:
|
||||||
borgCreate(project, database=database, sqlite_db=sqlite_db)
|
borgCreate(project, database=database)
|
||||||
else:
|
else:
|
||||||
borgCreate(project, path=paths[0], database=database, sqlite_db=sqlite_db)
|
borgCreate(project, path=paths[0], database=database)
|
||||||
|
|
||||||
for path in paths[1:]:
|
for path in paths[1:]:
|
||||||
archiveName = re.sub('/', '-', path)
|
archiveName = re.sub('/', '-', path)
|
||||||
borgCreate(f"{project}-{archiveName}", path=path)
|
borgCreate(f"{project}-{archiveName}", path=path)
|
||||||
|
|
||||||
|
|
||||||
def borgCreate(name, path=None, database=None, sqlite_db=None):
|
def borgCreate(name, path=None, database=None):
|
||||||
if path is None and database is None and sqlite_db is None:
|
if path is None and database 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)
|
print(f"Cannot create backup, you must pass at least one parameter amongst: path, database (archive name = {name}).", file=sys.stderr)
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
borgPaths = []
|
borgPaths = []
|
||||||
|
@ -72,22 +68,6 @@ def borgCreate(name, path=None, database=None, sqlite_db=None):
|
||||||
|
|
||||||
borgInput = dumpProc.stdout
|
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:
|
if path is None:
|
||||||
print(f"Creating archive '{name}' from database {database}.")
|
print(f"Creating archive '{name}' from database {database}.")
|
||||||
elif database is None:
|
elif database is None:
|
||||||
|
|
|
@ -1,14 +0,0 @@
|
||||||
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
|
|
|
@ -32,9 +32,6 @@ backup:
|
||||||
vaultwarden:
|
vaultwarden:
|
||||||
- /mnt/vwdata/attachments
|
- /mnt/vwdata/attachments
|
||||||
|
|
||||||
backup_sqlite:
|
|
||||||
stump: /mnt/stump/config/stump.db
|
|
||||||
|
|
||||||
borg_repo: /mnt/storagebox/backups/borg2
|
borg_repo: /mnt/storagebox/backups/borg2
|
||||||
borg_prune_opts:
|
borg_prune_opts:
|
||||||
- "--keep-within=1d"
|
- "--keep-within=1d"
|
||||||
|
@ -69,9 +66,6 @@ pasta:
|
||||||
postgres:
|
postgres:
|
||||||
ipv4: 10.86.16.1
|
ipv4: 10.86.16.1
|
||||||
ipv6: fc86::16
|
ipv6: fc86::16
|
||||||
stump:
|
|
||||||
ipv4: 10.86.18.1
|
|
||||||
ipv6: fc86::18
|
|
||||||
synapse:
|
synapse:
|
||||||
ipv4: 10.86.19.1
|
ipv4: 10.86.19.1
|
||||||
ipv6: fc86::19
|
ipv6: fc86::19
|
||||||
|
|
Loading…
Reference in a new issue