Skip to content

Add: GFS Backup Manager for LXC containers #384

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

stlas
Copy link

@stlas stlas commented May 14, 2025

GFS Backup Manager for LXC Containers

This script implements a GFS (Grandfather-Father-Son) backup rotation scheme for LXC containers in Proxmox VE.

Features

  • Automatic management of LXC container backups using GFS scheme
  • Configurable retention periods for:
    • Daily backups
    • Weekly archives
    • Monthly long-term archives
  • Dry-run mode for safe verification
  • Automatic backup storage detection
  • Comprehensive logging

Technical Details

  • Bash script with extensive error handling
  • Uses native Proxmox VE commands (pct, pvesm)
  • Safe backup handling with verification
  • Fully documented code

The script has been tested in a production environment.

Configuration

Main configuration options at the start of the script:

DAILY_RETENTION_DAYS="8"     # Days to keep daily backups
WEEKLY_RETENTION_WEEKS="12"  # Weeks to keep weekly archives
MONTHLY_RETENTION_MONTHS="12" # Months to keep monthly archives
DRY_RUN="1"                  # 1: Only show what would be done

Usage

The script can be run manually or as a cron job, ideal for automated backup management.

This script implements a GFS (Grandfather-Father-Son) backup rotation scheme for LXC containers in Proxmox VE.

Features:
- Configurable retention periods for daily, weekly, and monthly backups
- Dry-run mode for safe verification
- Automatic backup storage detection
- Comprehensive logging
- Error handling

The script has been tested in a production environment.
@stlas stlas requested a review from a team as a code owner May 14, 2025 16:29
Copy link
Member

@michelroegl-brunner michelroegl-brunner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One thing to add mybee:
When a user runs this script by hand and not as a cronjob, you get no output/visual clues for what is happening. Mybe you can incorporate /misc/core.func and use the msg_* function to make some nice messages for a user.

MONTHLY_RETENTION_MONTHS="12" # Months to keep monthly archives

DRY_RUN="1" # 1: Only show what would be done. 0: Actually delete (CAUTION!).
LOG_FILE="/var/log/lxc_backup_cleanup.log"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
LOG_FILE="/var/log/lxc_backup_cleanup.log"
LOG_FILE="/opt/community-scripts/log/lxc_backup_cleanup.log"

I know var/log is the typical place for logs, but we try to keep all community-script stuff in one folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants