diff --git a/imageroot/actions/restore-module/50restore_traefik b/imageroot/actions/restore-module/50restore_traefik new file mode 100755 index 0000000..8991789 --- /dev/null +++ b/imageroot/actions/restore-module/50restore_traefik @@ -0,0 +1,28 @@ +#!/bin/bash + +# +# Copyright (C) 2025 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +set -e + +shopt -s nullglob + +# Restore HTTP routes created from the UI: +for froute in state-backup/manual_flags/* ; do + route=$(basename "${froute}") + if [[ -f "state-backup/configs/${route}.yml" ]]; then + cp -vfT "state-backup/configs/${route}.yml" "configs/${route}.yml" + touch "manual_flags/${route}" + fi +done + +# Restore uploaded certificates (dynamic config): +find state-backup/configs -type f -name 'cert_*.yml' -0 | \ + xargs -0 -r -- cp -pvt configs/ + +# Restore uploaded certificates (certificates and private keys): +find state-backup/custom_certificates -type f -0 | \ + xargs -0 -r -- cp -pvt custom_certificates/ + diff --git a/imageroot/bin/module-cleanup-state b/imageroot/bin/module-cleanup-state index b88e7ea..27b8c41 100755 --- a/imageroot/bin/module-cleanup-state +++ b/imageroot/bin/module-cleanup-state @@ -1,8 +1,8 @@ -#!/usr/bin/env sh +#!/bin/bash # -# Copyright (C) 2023 Nethesis S.r.l. +# Copyright (C) 2025 Nethesis S.r.l. # SPDX-License-Identifier: GPL-3.0-or-later # -rm -fv backup-custom-routes.json +rm -rf state.backup diff --git a/imageroot/bin/module-dump-state b/imageroot/bin/module-dump-state new file mode 100644 index 0000000..f4922f2 --- /dev/null +++ b/imageroot/bin/module-dump-state @@ -0,0 +1,17 @@ +#!/bin/bash + +# +# Copyright (C) 2025 Nethesis S.r.l. +# SPDX-License-Identifier: GPL-3.0-or-later +# + +set -e + +rm -rf state-backup +mkdir -vp state-backup + +cp -pvT traefik.yaml state-backup/ +cp -prvT configs state-backup/configs/ +cp -prvT manual_flags state-backup/manual_flags/ +cp -prvT custom_certificates state-backup/custom_certificates/ +cp -prvT acme/ state-backup/acme/ diff --git a/imageroot/etc/state-include.conf b/imageroot/etc/state-include.conf new file mode 100644 index 0000000..21fb754 --- /dev/null +++ b/imageroot/etc/state-include.conf @@ -0,0 +1,6 @@ +# +# Restic include patterns for Traefik state +# Syntax reference: https://pkg.go.dev/path/filepath#Glob +# Restic --files-from: https://restic.readthedocs.io/en/stable/040_backup.html#including-files +# +state/state-backup