first commit

This commit is contained in:
julien
2024-12-03 00:49:51 +01:00
commit ba023e9f59
11 changed files with 244 additions and 0 deletions

61
scripts/netig-srv-backup Executable file
View File

@@ -0,0 +1,61 @@
#!/bin/bash
################################################################################
### Variables
# Source directory
source="/var/netig/srv"
# Destination directory
destination="/var/netig/bak"
# Backup file name
backup="bak_$(hostname -f)_$(date +"%Y%m%d").tar.zst"
################################################################################
### Down services
( cd /var/netig/srv/status.netig.net && docker compose down )
for f in /var/netig/srv/*
do
if [ -d "$f" ]; then
cd $f
docker compose down
fi
done
################################################################################
### Making the backup archive
echo
echo " Making the backup archive."
echo
tar --zstd -cf $destination/$backup -C $source .
################################################################################
### Up services
for f in /var/netig/srv/*
do
if [ -d "$f" ]; then
cd $f
if [ -d "django" ]
then
docker compose -f docker-compose.yml -f docker-compose.prod.yml up -d
else
docker compose up -d
fi
fi
done
################################################################################
### Remove destination archives older than n days
find $destination -name "bak_*" -type f -mtime +20 -delete
################################################################################
### End message
echo
echo " Backup done."
echo