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
+11
View File
@@ -0,0 +1,11 @@
#!/bin/bash
LOG_FILE="/var/log/backup_docker.log"
exec >> "$LOG_FILE" 2>&1
echo "script started at: $(date)"
sudo rsync -aq --delete --chown juulk:juulk /home/juulk/docker/ /mnt/pandorica/docker
echo "script ended at: $(date)"
echo "-------------------------------------------------------------------------------"
+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 {} \;
+19
View File
@@ -0,0 +1,19 @@
#!/bin/bash
LOG_FILE="/var/log/update_reboot.log"
REBOOT_FILE="/var/log/reboots.log"
exec >> "$LOG_FILE" 2>&1
echo "Script started at: $(date)"
sudo apt-get update && sudo apt-get upgrade -y
if [ -f /var/run/reboot-required ]; then
echo "Rebooting at: $(date)"
echo "-------------------------------------------------------------------------------"
echo "Rebooted at: $(date)" >> "$REBOOT_FILE"
sudo reboot now
fi
echo "No reboot required, script ended at: $(date)"
echo "-------------------------------------------------------------------------------"