From a49776d2ab20163fc321e18e57b9edf50273d76d Mon Sep 17 00:00:00 2001 From: tdpeuter Date: Sun, 3 Sep 2023 12:25:37 +0200 Subject: [PATCH] Modified stuff --- backups/create_calibre-web_backup.sh | 27 +++++++--------- backups/create_freshrss_backup.sh | 28 +++++++++++++++++ backups/create_gitea_backup.sh | 18 ++++++++--- backups/create_nextcloud_backup.sh | 15 ++++++--- backups/create_vaultwarden_backup.sh | 17 ++++++---- layout.txt | 47 ++++++++++++++++++++++++++++ 6 files changed, 121 insertions(+), 31 deletions(-) create mode 100644 backups/create_freshrss_backup.sh create mode 100644 layout.txt diff --git a/backups/create_calibre-web_backup.sh b/backups/create_calibre-web_backup.sh index f8fb0f5..309ee77 100755 --- a/backups/create_calibre-web_backup.sh +++ b/backups/create_calibre-web_backup.sh @@ -1,11 +1,16 @@ -#!/bin/bash -# Backup script for Calibre-web in a kubernetes cluster +#!/bin/sh +# Backup script for Calibre-web in a Kubernetes cluster + +PROGRAM_NAME='backup_calibre-web' +printlog () { + printf '%s: %s\n' "${PROGRAM_NAME}" "${1}" +} BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/calibre-web' DATABASE_FILE='/config/app.db' # Create filename for database backup -database_backupfile="calibre-web-app_$(date +'%Y%m%d').db" +database_backupfile="calibre-web-app_$( date +'%Y%m%d' ).db" # Retrieve container name base_container="$( docker ps --format '{{.Names}}' | grep tkioskje-calibre-web_tkioskje-calibre-web )" @@ -14,20 +19,12 @@ base_container="$( docker ps --format '{{.Names}}' | grep tkioskje-calibre-web_t set -e # Database backup ->&2 echo 'Backing up database' +printlog 'Backing up database' docker cp "${base_container}":"${DATABASE_FILE}" "${BACKUP_DEST}/${database_backupfile}" # Backup cleanup # Only keep 30 most recent backups ->&2 echo 'Cleaning up old database backups' -pushd "${BACKUP_DEST}" -excess="$( ls -x | head -n -30 )" -if [ -n "${excess}" ]; then - >&2 echo "Removing ${excess}" - rm "${excess}" -else - >&2 echo 'Skipping: nothing to remove' -fi -popd +printlog 'Cleaning up old database backups' +find "${BACKUP_DEST}" -type f -mtime +30 -print -delete ->&2 echo 'Done' +printlog 'Done' diff --git a/backups/create_freshrss_backup.sh b/backups/create_freshrss_backup.sh new file mode 100644 index 0000000..2424959 --- /dev/null +++ b/backups/create_freshrss_backup.sh @@ -0,0 +1,28 @@ +#!/bin/bash +# Backup script for FreshRSS in a Kubernetes cluster + +PROGRAM_NAME='backup_freshrss' +printlog () { + printf '%s: %s\n' "${PROGRAM_NAME}" "${1}" +} + +BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/freshrss' + +base_container="$( docker ps --format '{{.Names}}' | grep rss-freshrss_rss-freshrss )" + +# Abort entire script if any command fails +set -e + +# Enable maintenance mode +# TODO + +# Backup config +# TODO + +# Backup Database +# TODO + +# Disable maintenance mode +# TODO + +printlog 'Done' diff --git a/backups/create_gitea_backup.sh b/backups/create_gitea_backup.sh index d91edd6..f8de7f6 100755 --- a/backups/create_gitea_backup.sh +++ b/backups/create_gitea_backup.sh @@ -3,31 +3,37 @@ # `gitea dump` is a mess that we should not touch. We write our own backup scripts instead. +PROGRAM_NAME='backup_gitea' +printlog () { + printf '%s: %s\n' "${PROGRAM_NAME}" "${1}" +} + BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/gitea' PASSFILE='./gitea_pass.txt' # Retrieve container names -base_container="$( docker ps --format '{{.Names}}' | grep 'hugit-gitea_hugit-gitea' )" -database_container="$( docker ps --format '{{.Names}}' | grep 'hugit-postgresql_hugit-postgresql' )" +base_container="$( docker ps --format '{{.Names}}' | grep hugit-gitea_hugit-gitea )" +database_container="$( docker ps --format '{{.Names}}' | grep hugit-postgresql_hugit-postgresql )" # Abort entire script if any command fails set -e # Enable maintenance mode -# Flush queues +printlog 'Flushing queues' docker exec "${base_container}" gitea manager flush-queues # Pause queues # TODO # Backup the database ->&2 echo 'Backing up database' +printlog 'Backing up database' database_backupfile="gitea-sqlbkp_$( date +'%Y%m%d' ).bak" internal_database_backupfile="/tmp/${database_backupfile}" docker exec --env-file "${PASSFILE}" "${database_container}" pg_dump 'gitea' -cwv -h 'localhost' -U 'gitea' -f "${internal_database_backupfile}" docker cp "${database_container}":"${internal_database_backupfile}" "${BACKUP_DEST}" # Backup files -tar czvf "${BACKUP_DEST}/gitea-data_$(date +'%Y%m%d').tar.gz" -C "/mnt/APPS/hugit" +printlog 'Backing up files' +tar czvf "${BACKUP_DEST}/gitea-data_$( date +'%Y%m%d' ).tar.gz" -C "/mnt/APPS/hugit" # Disable maintenance mode # TODO @@ -35,3 +41,5 @@ tar czvf "${BACKUP_DEST}/gitea-data_$(date +'%Y%m%d').tar.gz" -C "/mnt/APPS/hugi # Double check # gitea doctor --all --log-file /tmp/doctor.log # TODO + +printlog 'Done' diff --git a/backups/create_nextcloud_backup.sh b/backups/create_nextcloud_backup.sh index a507fe6..0697ac7 100755 --- a/backups/create_nextcloud_backup.sh +++ b/backups/create_nextcloud_backup.sh @@ -1,11 +1,16 @@ #!/bin/bash -# Backup script for Nextcloud in a kubernetes cluster +# Backup script for Nextcloud in a Kubernetes cluster + +PROGRAM_NAME='backup_nextcloud' +printlog () { + printf '%s: %s\n' "${PROGRAM_NAME}" "${1}" +} BACKUP_DEST='/mnt/PRIVATE_DOCS/home/backup' PASSFILE='./nextcloud_pass.txt' # Create filename for database -database_backupfile="nextcloud-sqlbkp_$(date +'%Y%m%d').bak" +database_backupfile="nextcloud-sqlbkp_$( date +'%Y%m%d' ).bak" # Retrieve container names base_container="$( docker ps --format '{{.Names}}' | grep hugocloud-nextcloud_hugocloud-nextcloud )" @@ -18,7 +23,7 @@ set -e docker exec --user www-data "${base_container}" php occ maintenance:mode --on # Database backup ->&2 echo 'Backing up database' +printlog 'Backing up database' internal_database_backupfile="/tmp/${database_backupfile}" docker exec --env-file "${PASSFILE}" "${database_container}" pg_dump 'nextcloud' -cwv -h 'localhost' -U 'nextcloud' -f "${internal_database_backupfile}" docker cp "${database_container}":"${internal_database_backupfile}" "${BACKUP_DEST}" @@ -34,7 +39,7 @@ docker exec --user www-data "${base_container}" php occ maintenance:mode --off # Backup cleanup # Only keep 30 days of backups ->&2 echo 'Clean up old database backups' +printlog 'Clean up old database backups' find "${BACKUP_DEST}" -name '*sqlbkp*' -type f -mtime +30 -print -delete ->&2 echo 'Done' +printlog 'Done' diff --git a/backups/create_vaultwarden_backup.sh b/backups/create_vaultwarden_backup.sh index 652da10..a1a8c3a 100755 --- a/backups/create_vaultwarden_backup.sh +++ b/backups/create_vaultwarden_backup.sh @@ -1,11 +1,16 @@ #!/bin/bash -# Backup script for Vaultwarden in a kubernetes cluster +# Backup script for Vaultwarden in a Kubernetes cluster + +PROGRAM_NAME='backup_vaultwarden' +printlog () { + printf '%s: %s\n' "${PROGRAM_NAME}" "${1}" +} BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/vaultwarden' PASSFILE='./vaultwarden_pass.txt' # Create filename for database -database_backupfile="vaultwarden-sqlbkp_$(date +'%Y%m%d').bak" +database_backupfile="vaultwarden-sqlbkp_$( date +'%Y%m%d' ).bak" # Retrieve container names base_container="$( docker ps --format '{{.Names}}' | grep vaultwarden_vaultwarden )" @@ -15,7 +20,7 @@ database_container="$( docker ps --format '{{.Names}}' | grep vaultwarden-postgr set -e # Database backup ->&2 echo 'Backing up database' +printlog 'Backing up database' internal_database_backupfile="/tmp/${database_backupfile}" # Create backup file in docker container docker exec --env-file "${PASSFILE}" "${database_container}" pg_dump 'vaultwarden' -cwv -h 'localhost' -U 'vaultwarden' -f "${internal_database_backupfile}" @@ -24,13 +29,13 @@ docker cp "${database_container}":"${internal_database_backupfile}" "${BACKUP_DE # Files backup for file in 'attachments' 'sends' 'config.json' 'rsa_key.pem' 'rsa_key.pub.pem'; do - >&2 printf 'Copying %s\n' "${file}" + printlog "$( printf 'Copying %s\n' "${file}" )" docker cp -a "${base_container}":"/data/${file}" "${BACKUP_DEST}" done # Backup cleanup # Only keep 30 days of backups, seems about right. ->&2 echo 'Cleaning up old database backups' +printlog 'Cleaning up old database backups' find "${BACKUP_DEST}" -name '*sqlbkp*' -type f -mtime +30 -print -delete ->&2 echo 'Done' +printlog 'Done' diff --git a/layout.txt b/layout.txt new file mode 100644 index 0000000..d75579d --- /dev/null +++ b/layout.txt @@ -0,0 +1,47 @@ + + Router------------------------------ + | (Ethernet) + ----------------------H------------------------ + | | + | | + (Thunderbolt)= =(USB A)-----------Dock 1 + | | + | Dell Precision 7560 | + | | + ---(Thunderbolt)= =(USB A)-----------Dock 2 + | | | + | | | + | ----------------------------------------------- + | + | + ---------------------------- + | + | + -----------H------------ + | | + | | + AC----(Powerline)= =(Thunderbolt)----4TB Disk 3 + | | + | | + | | + (Ethernet)= =(USB A)----------2TB Disk + | | + | | + | | + 4TB Disk 1--------(USB A)= | + | | + | Dell Docking Station | + | | + 4TB Disk 2--------(USB A)= | + | | + | | + | | + (DisplayPort)= | + | | + | | + | | + (HDMI)= | + | | + | | + ------------------------ +