added custome cron scripts

This commit is contained in:
juul
2025-05-22 17:28:27 +02:00
parent 00e713e48f
commit 73f4fb3078
3 changed files with 46 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
#!/bin/bash
# Variables
LOCATION="/home/juulk/docker/postgresql"
RETENTION=7
DATE=$(date +"%Y-%m-%d_%H-%M-%S")
FILENAME="backup-$DATE.sql"
# Dump all databases
docker exec -u postgres postgres pg_dumpall > "$LOCATION/$FILENAME"
# Zip dump
gzip "$LOCATION/$FILENAME"
# Delete old backups
find "$LOCATION" -name "backup-*.sql.gz" -type f -mtime +$RETENTION -exec rm {} \;