Modified stuff

This commit is contained in:
Tibo De Peuter 2023-09-03 12:25:37 +02:00
parent 088bb700ab
commit a49776d2ab
6 changed files with 121 additions and 31 deletions

View file

@ -1,11 +1,16 @@
#!/bin/bash #!/bin/sh
# Backup script for Calibre-web in a kubernetes cluster # 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' BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/calibre-web'
DATABASE_FILE='/config/app.db' DATABASE_FILE='/config/app.db'
# Create filename for database backup # 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 # Retrieve container name
base_container="$( docker ps --format '{{.Names}}' | grep tkioskje-calibre-web_tkioskje-calibre-web )" 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 set -e
# Database backup # Database backup
>&2 echo 'Backing up database' printlog 'Backing up database'
docker cp "${base_container}":"${DATABASE_FILE}" "${BACKUP_DEST}/${database_backupfile}" docker cp "${base_container}":"${DATABASE_FILE}" "${BACKUP_DEST}/${database_backupfile}"
# Backup cleanup # Backup cleanup
# Only keep 30 most recent backups # Only keep 30 most recent backups
>&2 echo 'Cleaning up old database backups' printlog 'Cleaning up old database backups'
pushd "${BACKUP_DEST}" find "${BACKUP_DEST}" -type f -mtime +30 -print -delete
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
>&2 echo 'Done' printlog 'Done'

View file

@ -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'

View file

@ -3,31 +3,37 @@
# `gitea dump` is a mess that we should not touch. We write our own backup scripts instead. # `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' BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/gitea'
PASSFILE='./gitea_pass.txt' PASSFILE='./gitea_pass.txt'
# Retrieve container names # Retrieve container names
base_container="$( docker ps --format '{{.Names}}' | grep 'hugit-gitea_hugit-gitea' )" base_container="$( docker ps --format '{{.Names}}' | grep hugit-gitea_hugit-gitea )"
database_container="$( docker ps --format '{{.Names}}' | grep 'hugit-postgresql_hugit-postgresql' )" database_container="$( docker ps --format '{{.Names}}' | grep hugit-postgresql_hugit-postgresql )"
# Abort entire script if any command fails # Abort entire script if any command fails
set -e set -e
# Enable maintenance mode # Enable maintenance mode
# Flush queues printlog 'Flushing queues'
docker exec "${base_container}" gitea manager flush-queues docker exec "${base_container}" gitea manager flush-queues
# Pause queues # Pause queues
# TODO # TODO
# Backup the database # Backup the database
>&2 echo 'Backing up database' printlog 'Backing up database'
database_backupfile="gitea-sqlbkp_$( date +'%Y%m%d' ).bak" database_backupfile="gitea-sqlbkp_$( date +'%Y%m%d' ).bak"
internal_database_backupfile="/tmp/${database_backupfile}" 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 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}" docker cp "${database_container}":"${internal_database_backupfile}" "${BACKUP_DEST}"
# Backup files # 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 # Disable maintenance mode
# TODO # TODO
@ -35,3 +41,5 @@ tar czvf "${BACKUP_DEST}/gitea-data_$(date +'%Y%m%d').tar.gz" -C "/mnt/APPS/hugi
# Double check # Double check
# gitea doctor --all --log-file /tmp/doctor.log # gitea doctor --all --log-file /tmp/doctor.log
# TODO # TODO
printlog 'Done'

View file

@ -1,11 +1,16 @@
#!/bin/bash #!/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' BACKUP_DEST='/mnt/PRIVATE_DOCS/home/backup'
PASSFILE='./nextcloud_pass.txt' PASSFILE='./nextcloud_pass.txt'
# Create filename for database # 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 # Retrieve container names
base_container="$( docker ps --format '{{.Names}}' | grep hugocloud-nextcloud_hugocloud-nextcloud )" 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 docker exec --user www-data "${base_container}" php occ maintenance:mode --on
# Database backup # Database backup
>&2 echo 'Backing up database' printlog 'Backing up database'
internal_database_backupfile="/tmp/${database_backupfile}" 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 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}" 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 # Backup cleanup
# Only keep 30 days of backups # 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 find "${BACKUP_DEST}" -name '*sqlbkp*' -type f -mtime +30 -print -delete
>&2 echo 'Done' printlog 'Done'

View file

@ -1,11 +1,16 @@
#!/bin/bash #!/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' BACKUP_DEST='/mnt/PRIVATE_DOCS/BACKUPS/vaultwarden'
PASSFILE='./vaultwarden_pass.txt' PASSFILE='./vaultwarden_pass.txt'
# Create filename for database # 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 # Retrieve container names
base_container="$( docker ps --format '{{.Names}}' | grep vaultwarden_vaultwarden )" base_container="$( docker ps --format '{{.Names}}' | grep vaultwarden_vaultwarden )"
@ -15,7 +20,7 @@ database_container="$( docker ps --format '{{.Names}}' | grep vaultwarden-postgr
set -e set -e
# Database backup # Database backup
>&2 echo 'Backing up database' printlog 'Backing up database'
internal_database_backupfile="/tmp/${database_backupfile}" internal_database_backupfile="/tmp/${database_backupfile}"
# Create backup file in docker container # 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}" 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 # Files backup
for file in 'attachments' 'sends' 'config.json' 'rsa_key.pem' 'rsa_key.pub.pem'; do 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}" docker cp -a "${base_container}":"/data/${file}" "${BACKUP_DEST}"
done done
# Backup cleanup # Backup cleanup
# Only keep 30 days of backups, seems about right. # 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 find "${BACKUP_DEST}" -name '*sqlbkp*' -type f -mtime +30 -print -delete
>&2 echo 'Done' printlog 'Done'

47
layout.txt Normal file
View file

@ -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)= |
| |
| |
------------------------