#!/bin/bash # Configuration desired_network="your_local_network" # Replace with the actual process name # You can find it with: ps -eo comm= process_to_find="Minecraft_Bedro" dir_to_backup="/home/deck/.local/share/mcpelauncher/games/com.mojang/minecraftWorlds/" backup_path="/home/deck/Documents/mc_bedrock_backups/" max_backups=48 # Set the maximum number of backups to keep # Interval Values found_network=false found_process=false # Check if the desired network is found wireless_network_names=$(nmcli -t -f active,ssid dev wifi | grep yes | cut -d: -f2) for network in $wireless_network_names; do if [ "$network" == "$desired_network" ]; then found_network=true break fi done # If the desired network is not found, print a message and exit if [ "$found_network" != true ]; then echo "The desired network was not found. Not running..." exit 1 fi # Check if the desired process is running if pgrep -x "$process_to_find" > /dev/null; then found_process=true else echo "The desired process is not running. Not creating backups..." exit 1 fi cd "$dir_to_backup" # Backup the directory and save it with maximum compression backup_filename="backup_$(date '+%Y%m%d_%H%M%S').zip" zip -r -9 "$backup_path/$backup_filename" "./" # Check if the zip process was successful if [ $? -eq 0 ]; then echo "Backup successful. Saved to: $backup_path/$backup_filename" # Remove older backups to keep only the last N backups ls -t "$backup_path" | tail -n +$((max_backups + 1)) | xargs -I {} rm -- "$backup_path/{}" echo "Older backups removed to keep the last $max_backups backups." else echo "Backup failed." fi