docker restart policies and fixes on backups & setups after re-settuping the whole server

This commit is contained in:
Hurlu 2026-01-12 23:44:52 +01:00
parent edc2930086
commit 120974b6d8
12 changed files with 120 additions and 24 deletions

View File

@ -1,12 +1,12 @@
#!/bin/bash
mkdir ~GDriveBackup/.
rclone copy rootGdrive: ~/GDriveBackup/.
mkdir ~/gdrivebackup
rclone copy rootGdrive: ~/gdrivebackup/.
EPOCH=$(date +%s)
tar -cpf ~/backups/GDriveBackup_$EPOCH.tar ~/GDriveBackup;
rm -rf ~/GDriveBackup
BACKUP_COUNT=$(ls -tU ~/backups/ | wc -l)
SIZE_DISK=$(df -h / --output=avail | tail -1) #if less than 100G available
tar -cpf ~/backups/gdrivebackup_$EPOCH.tar ~/gdrivebackup;
rm -rf ~/gdrivebackup
BACKUP_COUNT=$(ls -tU ~/backups/gdrivebackup_* | wc -l)
SIZE_DISK=$(df / --output=avail | tail -1) #if less than 100G available
if [[ $BACKUP_COUNT -gt 10 ]] || [[ $SIZE_DISK -lt 100000000 ]]
then rm $(ls -tU ~/backups | head -1) # delete oldest backup
then rm $(ls -tU ~/backups/gdrivebackup_* | head -1) # delete oldest backup
fi

View File

@ -10,7 +10,7 @@ fi
apt update;
apt upgrade;
apt install -y docker docker-compose python3 curl nmap emacs-nox unzip zip htop postfix tree;
apt install -y docker docker-compose python3 curl nmap emacs-nox unzip zip htop postfix tree httpie jq;
curl https://rclone.org/install.sh | sudo bash
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
@ -45,3 +45,7 @@ cd $GLOB_DIR/gitea
# run server containers
# enjoy :]
#add current user to dockergroup
usermod -a -G docker $USER
nexgrp docker

View File

@ -2,11 +2,11 @@ services:
hangftp:
image: drakkan/sftpgo:v2.6.6-alpine-slim
container_name: hang_ftp
restart:always
restart: always
networks:
- traefik_default
volumes:
- /mnt/Music:/srv/sftpgo/data
- /home/hurlu/music:/srv/sftpgo/data
- ./conf-hangsftpgo:/var/lib/sftpgo
labels:
- "traefik.enable=true"

View File

@ -4,6 +4,6 @@ docker exec -u git -w "/data/git" $(docker ps -qf "name=^/gitea$") bash -c "/app
cd $SCRIPT_DIR;
mv gitea_data/git/gitea-dump* gitea_backup.zip;
rm -f gitea_data/git/gitea-dump*;
rclone copy gitea_backup.zip Gdrive:/;
rclone copy gitea_backup.zip GDrive:/;
rm -f gitea_backup.zip;

91
gitea/restore.sh Executable file
View File

@ -0,0 +1,91 @@
# open gitea_db docker
# use gitea_db secrets to put the content of the gitea_db.sql file into psql, like joplin's restore.sh
#!/bin/bash
SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
if [[ $1 == "" ]]
then
echo "./restore.sh [gitea backup zip file name]"
exit 1
else
read -r -p "Assuming $1 is the gitea zip backup file: is it correct ? (y/n) " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
FILE_NAME=$1
else
exit 1
fi
fi
read -r -p "Have you started the docker container ? (y/n) " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
read -r -p "Have you started the install wizard ? (you shouldn't have) (y/n) " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "Too soon for the web install wizard, start over the backup process."
exit 1
fi
else
echo "Then do it, and launch this script again afterwards !"
exit 1
fi
unzip -d $SCRIPT_DIR/unzipped $1
#restore gitea's postgres DB
sudo mv $SCRIPT_DIR/unzipped/gitea-db.sql $SCRIPT_DIR/postgres/.
source $SCRIPT_DIR/secrets/gitea_db.secret
docker exec \
-e POSTGRES_USER \
-e POSTGRES_DB \
gitea_db \
bash -c "psql -U $POSTGRES_USER $POSTGRES_DB < /var/lib/postgresql/data/gitea-db.sql"
read -r -p "Have you started the docker container and did you got through the web install wizard ? (y/n) " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "Proceeding with backup restoration..."
else
read -r -p "Then just go do it ! Then where you're done, press Enter." response
fi
source $SCRIPT_DIR/secrets/gitea.secret
sudo mv -f $SCRIPT_DIR/unzipped gitea_data/.
#creating extra folder
docker exec gitea \
/bin/bash -c "mkdir -p /data/git/repositories"
#chown all to git
docker exec gitea \
/bin/bash -c "chown -R git:git /data"
#copy app.ini
docker exec gitea \
/bin/bash -c "cp /data/unzipped/app.ini /data/gitea/conf/."
#copy repos
docker exec gitea \
/bin/bash -c "cp -rf /data/unzipped/repos/* /data/git/repositories/."
#copy the rest
docker exec gitea \
/bin/bash -c "cp -rf /data/unzipped/data/* /data/gitea/."
#chown all to git again, to be safe
docker exec gitea \
/bin/bash -c "chown -R git:git /data"
#regen hooks
docker exec -u git gitea \
/bin/bash -c "/usr/local/bin/gitea -c '/data/gitea/conf/app.ini' admin regenerate hooks"
#one more tiiime
docker exec gitea \
/bin/bash -c "chown -R git:git /data"
sudo rm -rf gitea_data/unzipped

View File

@ -11,5 +11,5 @@ docker exec \
$(docker ps -qf "name=joplin_db") \
bash -c "pg_dump -U $POSTGRES_USER --clean --no-owner --no-privileges -d $POSTGRES_DB" > $SCRIPT_DIR/postgres_joplin.sql
rclone copy postgres_joplin.sql Gdrive:/
rclone copy postgres_joplin.sql GDrive:/
rm -f postgres_joplin.sql

View File

@ -6,7 +6,7 @@ services:
snapserver:
image: jaedb/snapserver
container_name: snapserver
restart:always
restart: always
depends_on:
mopidy:
condition: service_healthy
@ -29,7 +29,7 @@ services:
mopidy:
container_name: mopidy
restart:always
restart: always
build: ./
# image: jaedb/iris:3.70
environment:
@ -46,7 +46,7 @@ services:
- ./docker/mopidy/iris:/var/lib/mopidy/iris # Iris-specific storage
- ./docker/mopidy/m3u:/var/lib/mopidy/m3u # To persist local playlists
- ./docker/mopidy/mopidy.conf:/config/mopidy.conf
- /mnt/Music:/var/lib/mopidy/media
- /home/hurlu/music:/var/lib/mopidy/media
- /tmp/snapserver:/tmp
networks:
- traefik_default
@ -60,7 +60,7 @@ services:
guide:
image: dannyben/madness:1.2.5
container_name: hang_guide
restart:always
restart: always
volumes:
- ./markdown:/docs
networks:

View File

@ -1,14 +1,14 @@
services:
hangyoutube:
container_name: hang_youtube
restart:always
restart: always
image: ghcr.io/alexta69/metube:2025.12.14
mem_limit: 1400m
cpus: 0.8
networks:
- traefik_default
volumes:
- /mnt/Music:/downloads
- /home/hurlu/music:/downloads
labels:
- "traefik.enable=true"
- "traefik.http.routers.hangyoutube.rule=Host(`youtube.hang.hugowillaume.com`)"
@ -21,11 +21,11 @@ services:
hangspotify:
container_name: hang_spotify
image: ghcr.io/henriquesebastiao/downtify:1.1.1
restart:always
restart: always
networks:
- traefik_default
volumes:
- /mnt/Music:/downloads
- /home/hurlu/music:/downloads
mem_limit: 1400m
cpus: 0.8
labels:

View File

@ -2,7 +2,7 @@ SCRIPT_DIR=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
cd $SCRIPT_DIR;
zip -r -9 mealie.zip mealie;
rclone copy mealie.zip Gdrive:/;
rclone copy mealie.zip GDrive:/;
rm mealie.zip

View File

@ -22,3 +22,5 @@ echo '{"channel_name": "Le Coco", "channel_flag_permanent":1}' | $BASE_COMMAND/c
echo
echo '{"channel_name": "STREAM ON", "channel_flag_permanent":1}' | $BASE_COMMAND/channelcreate$API_KEY
echo
echo '{"channel_name": "FEBO", "channel_flag_permanent":1}' | $BASE_COMMAND/channelcreate$API_KEY
echo

View File

@ -10,7 +10,6 @@ services:
- 9987:9987/udp #udp voice port
- 10080:10080
- 30033:30033 #file transfer port
restart: unless-stopped
env_file: ./secrets/teamspeak.secret
volumes:
- ./data:/var/ts3server/

View File

@ -6,7 +6,7 @@ services:
traefik:
image: "traefik:v2.5.3"
container_name: "traefik"
restart:always
restart: always
networks:
- default
ports:
@ -31,7 +31,7 @@ services:
traefik-forward-auth:
image: thomseddon/traefik-forward-auth:2
container_name: auth_forward
restart:always
restart: always
networks:
- default
env_file: secrets/traefik_forward_auth.secret