Last active
July 19, 2024 12:10
-
-
Save Masu-Baumgartner/1a533000c289dcc87f347e9a31a5ca70 to your computer and use it in GitHub Desktop.
A small cleanup script for pterodactyl servers to free some diskspace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/bash | |
cd /var/lib/pterodactyl/volumes | |
# Get the initial free disk space | |
initial_space=$(df -h . | awk 'NR==2 {print $4}') | |
echo "1. Clearing docker caches, stopped containers, unused images" | |
docker system prune --force | |
echo "2. Performing linux cleanups" | |
echo "- Clearing systemd journal" | |
journalctl --vacuum-size=500M | |
echo "- Clearing apt cache" | |
apt-get clean | |
echo "- Clearing ptero logs" | |
rm /var/log/pterodactyl/wings.log-* | |
echo "- Clearing ptero install logs" | |
rm /var/log/pterodactyl/install/* | |
echo "- Clearing log rotation archives" | |
rm /var/log/alternatives.log.* | |
rm /var/log/apport.log.* | |
rm /var/log/auth.log.* | |
rm /var/log/dmesg.*.gz | |
rm /var/log/dpkg.log.*.gz | |
rm /var/log/kern.log.*.gz | |
rm /var/log/letsencrypt/letsencrypt.log.* | |
echo "3. Clearing ptero volumes" | |
echo "- Deleting oversized and old logs" | |
# logs | |
find . -type f -name "*.log" -path "*" -size +10M -exec sh -c 'echo "Deleting: $1"; rm "$1"' _ {} \; | |
find . -type f -name "*.log" -path "*" -mtime +60 -exec sh -c 'echo "Deleting: $1"; rm "$1"' _ {} \; | |
echo "- Deleting cache/old/unused files" | |
# Paper cache files | |
find . -type f -name "*.jar" -path "*/cache/*" -exec sh -c 'echo "Deleting: $1"; rm "$1"' _ {} \; | |
find . -type f -name "paper-*.jar" -path "*/versions/*" -mtime +90 -exec sh -c 'echo "Deleting: $1"; rm "$1"' _ {} \; | |
# Ptero egg old server jar | |
find . -type f -name "server.jar.old" -path "*" -exec sh -c 'echo "Deleting: $1"; rm "$1"' _ {} \; | |
# Mc bedrock debug files | |
find . -type f -name "bedrock_server_symbols.debug" -path "*" -exec sh -c 'echo "Deleting: $1"; rm "$1"' _ {} \; | |
# Get the current free disk space | |
current_space=$(df -h . | awk 'NR==2 {print $4}') | |
echo "============================" | |
echo "Summary:" | |
echo "Initial Free Space: $initial_space" | |
echo "Current Free Space: $current_space" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment