From 0df97444c7acfc41de6255752c2c5fe08d23b4ba Mon Sep 17 00:00:00 2001 From: Ludovic Cartier Date: Wed, 27 May 2026 18:42:30 +0200 Subject: [PATCH] add sshportal backup --- README.md | 14 ++++++++++++++ templates/brain_backup.j2 | 19 +++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/README.md b/README.md index ee8eea0..56e6a0d 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,7 @@ The custom script : - can dump MariaDB database(s), including routines/events/triggers - can dump PostgreSQL database(s) - can dump Gitea data + - can dump sshportal data All files are then send it to a custom Proxmox Backup Server. @@ -64,6 +65,12 @@ Role variables | backup_gitea_docker_container | string | | | required if docker enabled | | backup_gitea_docker_workdir | string | | /backup | container workdir where gitea dump is generated | | backup_gitea_docker_host_temp_dir | string | | {{ backup_dir }}/temp | host temp dir mounted in container | +| backup_sshportal_enabled | boolean | | false | enable sshportal backup | +| backup_sshportal_db_path | string | | /var/lib/docker/volumes/sshportal__var_lib_sshportal/_data/sshportal.db | sqlite db path | +| backup_sshportal_ssh_host | string | | localhost | ssh host | +| backup_sshportal_ssh_port | string | | 2222 | ssh port | +| backup_sshportal_ssh_user | string | | admin | ssh user | +| backup_sshportal_ssh_key | string | | /opt/docker-compose/sshportal/ed25519_sshportal_admin | ssh private key | | backup_cron_minute | int | | | | | backup_cron_hour | int | | | | @@ -132,6 +139,13 @@ backup_gitea_config: '/data/gitea/conf/app.ini' backup_gitea_docker_enabled: true backup_gitea_docker_container: 'gitea' +backup_sshportal_enabled: true +backup_sshportal_db_path: '/var/lib/docker/volumes/sshportal__var_lib_sshportal/_data/sshportal.db' +backup_sshportal_ssh_host: 'localhost' +backup_sshportal_ssh_port: '2222' +backup_sshportal_ssh_user: 'admin' +backup_sshportal_ssh_key: '/opt/docker-compose/sshportal/ed25519_sshportal_admin' + backup_cron_minute: 30 backup_cron_hour: 5 ``` diff --git a/templates/brain_backup.j2 b/templates/brain_backup.j2 index 671ff31..d388964 100644 --- a/templates/brain_backup.j2 +++ b/templates/brain_backup.j2 @@ -221,6 +221,22 @@ fi ## end of gitea ## {% endif %} +{% if backup_sshportal_enabled is sameas true %} +## sshportal ## +backup_sshportal_db_path="{{ backup_sshportal_db_path | default('/var/lib/docker/volumes/sshportal__var_lib_sshportal/_data/sshportal.db') }}" +backup_sshportal_ssh_host="{{ backup_sshportal_ssh_host | default('localhost') }}" +backup_sshportal_ssh_port="{{ backup_sshportal_ssh_port | default('2222') }}" +backup_sshportal_ssh_user="{{ backup_sshportal_ssh_user | default('admin') }}" +backup_sshportal_ssh_key="{{ backup_sshportal_ssh_key | default('/opt/docker-compose/sshportal/ed25519_sshportal_admin') }}" + +mkdir -p "$backup_dir/$today/sshportal" + +/usr/bin/sqlite3 "$backup_sshportal_db_path" .dump > "$backup_dir/$today/sshportal/sshportal.sql.bkp" + +/usr/bin/ssh -i "$backup_sshportal_ssh_key" -p "$backup_sshportal_ssh_port" -l "$backup_sshportal_ssh_user" "$backup_sshportal_ssh_host" config backup > "$backup_dir/$today/sshportal/backup.json" +## end of sshportal ## +{% endif %} + # purge old backups find $backup_dir -type d -ctime +$backup_local_retention -exec rm -rf {} \; @@ -253,6 +269,9 @@ mariadb.pxar:$backup_dir/$today/mariadb \ {% if backup_gitea_enabled is sameas true %} gitea.pxar:$backup_dir/$today/gitea \ {% endif %} +{% if backup_sshportal_enabled is sameas true %} +sshportal.pxar:$backup_dir/$today/sshportal \ +{% endif %} --rate ${PBS_RATE} ## end of send to PBS ##