Skip to content

Commit

Permalink
makes backup rotation optional
Browse files Browse the repository at this point in the history
(cherry picked from commit 42a019b)
  • Loading branch information
Robert Anniés authored and svaningelgem committed Jul 25, 2024
1 parent 164b974 commit 67dcbe9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 3 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ MAX_RETRIES=""
RETRY_DELAY_SECS=""

## If you do not wish to recieve any emails or alerts on script failure please set SEND_EMAILS="False" ##

SEND_EMAILS="True"

## Removes older backups when the backup limit counter in the Pterodactyl server settings is reached (backups fail otherwise).
ROTATE="True"

# This is for email alerts if the script fails or some servers do not backup
# if using gmail please enable 2FA and generate an app specific password. https://support.google.com/accounts/answer/185833?hl=en

Expand Down
4 changes: 3 additions & 1 deletion backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
API_KEY = f"Bearer {os.getenv('API_KEY')}"
SERVERS_URL = os.getenv("SERVERS_URL")
SEND_EMAILS = os.getenv("SEND_EMAILS", "True") # Default to "True" if not set
ROTATE = os.getenv("ROTATE", "False") # Default to "False" if not set
POST_BACKUP_SCRIPT = os.getenv("POST_BACKUP_SCRIPT") # optional

# Instantiate EmailAlert object
Expand Down Expand Up @@ -165,6 +166,7 @@ def run_script(server_id, backup_uuid):
logger.error(f"post backup script: failed with exit status {exit_status}")

(server_ids, backup_limits) = make_request()
remove_old_backups(backup_limits)
if ROTATE.lower() == "true":
remove_old_backups(backup_limits)
backup_servers(server_ids)

0 comments on commit 67dcbe9

Please sign in to comment.