BastilleBSD/Paperless-ngx/upgrade.sh hinzugefügt
This commit is contained in:
60
BastilleBSD/Paperless-ngx/upgrade.sh
Normal file
60
BastilleBSD/Paperless-ngx/upgrade.sh
Normal file
@@ -0,0 +1,60 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# upgrade-paperless-postgres.sh
|
||||
# Ablauf: Paperless -> Postgres -> Paperless (im BastilleBSD-Jail)
|
||||
#
|
||||
|
||||
set -e # bei Fehler abbrechen
|
||||
|
||||
JAIL="paperless"
|
||||
DB_NAME="paperless"
|
||||
DB_USER="paperless"
|
||||
OLD_PG_VER="16"
|
||||
NEW_PG_VER="17"
|
||||
BACKUP_DIR="/root/pg_backup"
|
||||
DUMPFILE="$BACKUP_DIR/paperless_$(date +%Y%m%d_%H%M%S).sql"
|
||||
|
||||
echo ">>> Schritt 1: Paperless-Services im Jail stoppen"
|
||||
bastille cmd $JAIL service paperless stop || true
|
||||
bastille cmd $JAIL service redis stop || true
|
||||
|
||||
echo ">>> Schritt 2: Postgres-Dump ziehen"
|
||||
bastille cmd $JAIL mkdir -p "$BACKUP_DIR"
|
||||
bastille cmd $JAIL su - postgres -c "\"pg_dump -U $DB_USER $DB_NAME > $DUMPFILE\""
|
||||
echo "Backup gespeichert unter: $DUMPFILE"
|
||||
|
||||
echo ">>> Schritt 3: Alte Postgres-Instanz im Jail stoppen"
|
||||
bastille cmd $JAIL service postgresql stop || true
|
||||
|
||||
echo ">>> Schritt 4: Neue Postgres-Version installieren"
|
||||
bastille cmd $JAIL pkg install -y postgresql${NEW_PG_VER}-server postgresql${NEW_PG_VER}-client
|
||||
|
||||
echo ">>> Schritt 5: Neues Datenverzeichnis initialisieren"
|
||||
bastille cmd $JAIL mv /var/db/postgres/data${OLD_PG_VER} /var/db/postgres/data${OLD_PG_VER}.old.$(date +%s) || true
|
||||
bastille cmd $JAIL sysrc postgresql_enable="YES"
|
||||
bastille cmd $JAIL service postgresql initdb
|
||||
bastille cmd $JAIL service postgresql start
|
||||
|
||||
echo ">>> Schritt 6: Backup einspielen"
|
||||
bastille cmd $JAIL su - postgres -c "\"psql -U $DB_USER -d $DB_NAME -f $DUMPFILE\""
|
||||
|
||||
echo ">>> Schritt 7: Paperless-Upgrade (auto erkennen)"
|
||||
if bastille cmd $JAIL pkg info paperless-ngx >/dev/null 2>&1; then
|
||||
echo ">>> Paperless via pkg erkannt – Upgrade mit pkg"
|
||||
bastille cmd $JAIL pkg upgrade -y paperless-ngx
|
||||
elif bastille cmd $JAIL pip show paperless-ngx >/dev/null 2>&1; then
|
||||
echo ">>> Paperless via pip erkannt – Upgrade mit pip"
|
||||
bastille cmd $JAIL pip install -U paperless-ngx
|
||||
else
|
||||
echo ">>> WARNUNG: Paperless-Installation nicht gefunden!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo ">>> Schritt 8: Datenbankmigration Paperless"
|
||||
bastille cmd $JAIL sh -c "cd /usr/local/lib/python3.11/site-packages/paperless && python3.11 manage.py migrate"
|
||||
|
||||
echo ">>> Schritt 9: Dienste starten"
|
||||
bastille cmd $JAIL service redis start
|
||||
bastille cmd $JAIL service paperless start
|
||||
|
||||
echo ">>> Upgrade abgeschlossen ✅"
|
||||
Reference in New Issue
Block a user