diff --git a/modules/backup.nix b/modules/backup.nix index f3e841a..03d6ec0 100644 --- a/modules/backup.nix +++ b/modules/backup.nix @@ -27,16 +27,16 @@ in sleep 2 docker exec minecraft rcon-cli save-off - # Compress world data (re-enable saving even if tar fails) - if ! ${pkgs.gnutar}/bin/tar czf "$TEMP_BACKUP" \ - -C ${mcDataDir} world; then - echo "tar failed, re-enabling saving" - docker exec minecraft rcon-cli save-on - exit 1 - fi + # Ensure save-on runs no matter how the script exits from here + trap 'docker exec minecraft rcon-cli save-on' EXIT - # Re-enable saving immediately + # Compress world data + ${pkgs.gnutar}/bin/tar czf "$TEMP_BACKUP" \ + -C ${mcDataDir} world + + # Re-enable saving immediately (trap will also fire, but save-on is idempotent) docker exec minecraft rcon-cli save-on + trap - EXIT # Upload to B2 (overwrites the single backup file) B2_ACCOUNT=$(cat ${config.age.secrets.b2-account-id.path}) @@ -47,8 +47,17 @@ in ":b2:${b2Bucket}/world-latest.tar.gz" \ --b2-account "$B2_ACCOUNT" \ --b2-key "$B2_KEY" \ + --b2-hard-delete \ + --config /dev/null \ --no-check-dest + # Purge old file versions to stay under storage cap + ${pkgs.rclone}/bin/rclone cleanup \ + ":b2:${b2Bucket}" \ + --b2-account "$B2_ACCOUNT" \ + --b2-key "$B2_KEY" \ + --config /dev/null + # Clean up local temp file rm -f "$TEMP_BACKUP" diff --git a/modules/discord.nix b/modules/discord.nix index 891bc46..0f375d4 100644 --- a/modules/discord.nix +++ b/modules/discord.nix @@ -31,7 +31,7 @@ in "playerCountVoiceChannelId": "", "useWebhook": true, "updateChannelTopic": true, - "channelUpdateInterval": 300000, + "channelUpdateInterval": 600000, "allowedMentions": ["users", "roles"], "broadcastPlayerCommandExecution": false, "announceServerStartStop": true,