test other version
Some checks failed
Ansible Minecraft CI/CD Pipeline / Ansible Lint Check (push) Successful in 58s
Ansible Minecraft CI/CD Pipeline / Project Structure Validation (push) Failing after 3s
Ansible Minecraft CI/CD Pipeline / Security Scan (push) Successful in 4s
Ansible Minecraft CI/CD Pipeline / Deploy to Staging (push) Has been skipped
Ansible Minecraft CI/CD Pipeline / Deploy to Production (push) Has been skipped
Ansible Minecraft CI/CD Pipeline / Backup System Check (push) Has been skipped
Some checks failed
Ansible Minecraft CI/CD Pipeline / Ansible Lint Check (push) Successful in 58s
Ansible Minecraft CI/CD Pipeline / Project Structure Validation (push) Failing after 3s
Ansible Minecraft CI/CD Pipeline / Security Scan (push) Successful in 4s
Ansible Minecraft CI/CD Pipeline / Deploy to Staging (push) Has been skipped
Ansible Minecraft CI/CD Pipeline / Deploy to Production (push) Has been skipped
Ansible Minecraft CI/CD Pipeline / Backup System Check (push) Has been skipped
This commit is contained in:
38
roles/04-backups/tasks/05-setup-backup-scripts.yml
Normal file
38
roles/04-backups/tasks/05-setup-backup-scripts.yml
Normal file
@@ -0,0 +1,38 @@
|
||||
---
|
||||
- name: Create backup utility script
|
||||
ansible.builtin.copy:
|
||||
content: |
|
||||
#!/bin/bash
|
||||
# Backup utility functions
|
||||
|
||||
# Function to stop Minecraft server safely
|
||||
stop_minecraft() {
|
||||
if systemctl is-active --quiet minecraft; then
|
||||
echo "Stopping Minecraft server..."
|
||||
/usr/local/bin/mcrcon -H 127.0.0.1 -P {{ rcon_port }} -p "{{ rcon_password }}" "say Server backup starting in 30 seconds..."
|
||||
sleep 30
|
||||
/usr/local/bin/mcrcon -H 127.0.0.1 -P {{ rcon_port }} -p "{{ rcon_password }}" stop
|
||||
sleep 10
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to start Minecraft server
|
||||
start_minecraft() {
|
||||
if ! systemctl is-active --quiet minecraft; then
|
||||
echo "Starting Minecraft server..."
|
||||
systemctl start minecraft
|
||||
fi
|
||||
}
|
||||
|
||||
# Function to clean old backups
|
||||
clean_old_backups() {
|
||||
local backup_dir=$1
|
||||
local retention_days=$2
|
||||
|
||||
find "$backup_dir" -type f -mtime +$retention_days -delete
|
||||
find "$backup_dir" -type d -empty -delete
|
||||
}
|
||||
dest: "{{ minecraft_tools_dir }}/backup-functions.sh"
|
||||
owner: "{{ minecraft_user }}"
|
||||
group: "{{ minecraft_group }}"
|
||||
mode: '0755'
|
Reference in New Issue
Block a user