Skip to content

The AI Layer for Linux — Intelligent backup & restore system. Smart rsync • Btrfs/LVM snapshots • S3/B2/GCS cloud sync

License

Notifications You must be signed in to change notification settings

cortexlinux/cortex-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cortex Backup

AI-Assisted Backup System for Cortex Linux

License Python

Overview

Cortex Backup provides intelligent, automated backups with rsync, filesystem snapshots, and cloud synchronization for Cortex Linux servers.

Features

Feature Description
Smart Rsync Wrapper with intelligent defaults and excludes
Snapshots Btrfs and LVM snapshot management
Cloud Sync S3, Backblaze B2, and Google Cloud Storage
Restore Wizard Interactive file browser and selective restore
Scheduling Systemd timer integration
Incremental Hard-link based incremental backups

Quick Start

# Install
pip install -e .

# Immediate backup
cortex-backup now

# Schedule daily backups
cortex-backup schedule daily --time 02:00

# List backups
cortex-backup list

# Restore
cortex-backup restore <backup-id>

# Sync to cloud
cortex-backup cloud sync

CLI Commands

Backup Operations

# Full system backup
cortex-backup now

# Backup specific path
cortex-backup now --source /home

# Incremental backup
cortex-backup now --incremental

# With custom excludes
cortex-backup now --exclude "*.log" --exclude "/tmp/*"

# Dry run
cortex-backup now --dry-run

List & Restore

# List backups
cortex-backup list

# Restore full backup
cortex-backup restore <backup-id>

# Restore to different location
cortex-backup restore <backup-id> --target /mnt/restore

# Restore specific files
cortex-backup restore <backup-id> --file /etc/nginx --file /var/www

Scheduling

# Daily backup at 2 AM
cortex-backup schedule daily --time 02:00

# Weekly backup on Sunday
cortex-backup schedule weekly --day 0 --time 03:00

# List schedules
cortex-backup schedule list

# Remove schedule
cortex-backup schedule remove daily

Cloud Storage

# Sync latest backup to cloud
cortex-backup cloud sync

# Sync specific backup
cortex-backup cloud sync <backup-id>

# Check cloud status
cortex-backup cloud status

Snapshots

# Create snapshot
cortex-backup snapshot create /

# List snapshots
cortex-backup snapshot list

Configuration

Environment variables (prefix: CORTEX_BACKUP_):

# Paths
CORTEX_BACKUP_BACKUP_DIR=/var/backups/cortex
CORTEX_BACKUP_DEFAULT_SOURCE=/

# Compression
CORTEX_BACKUP_COMPRESSION=zstd

# S3 / S3-compatible
CORTEX_BACKUP_S3__ACCESS_KEY=xxx
CORTEX_BACKUP_S3__SECRET_KEY=xxx
CORTEX_BACKUP_S3__BUCKET=my-backups
CORTEX_BACKUP_S3__REGION=us-east-1
CORTEX_BACKUP_S3__ENDPOINT_URL=https://s3.example.com  # For MinIO, etc.

# Backblaze B2
CORTEX_BACKUP_B2__APPLICATION_KEY_ID=xxx
CORTEX_BACKUP_B2__APPLICATION_KEY=xxx
CORTEX_BACKUP_B2__BUCKET_NAME=my-backups

# Google Cloud Storage
CORTEX_BACKUP_GCS__PROJECT_ID=my-project
CORTEX_BACKUP_GCS__BUCKET=my-backups
CORTEX_BACKUP_GCS__CREDENTIALS_FILE=/path/to/creds.json

# Retention
CORTEX_BACKUP_RETENTION__KEEP_DAILY=7
CORTEX_BACKUP_RETENTION__KEEP_WEEKLY=4
CORTEX_BACKUP_RETENTION__KEEP_MONTHLY=12

Default Excludes

The following paths are excluded by default:

  • /proc/*, /sys/*, /dev/*, /run/*
  • /tmp/*, /var/tmp/*, /var/cache/*
  • /swapfile, *.swap, /lost+found
  • .cache/, __pycache__/, node_modules/

Architecture

cortex_backup/
├── cli.py              # Typer CLI
├── config/             # Pydantic settings
├── core/               # Backup engine
│   ├── backup.py       # Main engine
│   ├── rsync.py        # Rsync wrapper
│   └── state.py        # State management
├── snapshot/           # Snapshot management
│   ├── btrfs.py        # Btrfs snapshots
│   └── lvm.py          # LVM snapshots
├── cloud/              # Cloud storage
│   ├── s3.py           # AWS S3
│   ├── b2.py           # Backblaze B2
│   └── gcs.py          # Google Cloud
├── restore/            # Restore functionality
│   ├── browser.py      # File browser
│   └── wizard.py       # Restore wizard
├── schedule/           # Scheduling
│   ├── scheduler.py    # Schedule management
│   └── systemd.py      # Systemd timers
└── utils/              # Utilities

License

Apache 2.0 - See LICENSE