backitup

A simple, powerful Linux server backup agent

Backup your Linux servers with ease

backitup is a Python-based backup agent that creates backups of MySQL/MariaDB databases and specified file directories.

Features

Database Backups

Backs up MySQL/MariaDB databases using mysqldump with support for all databases or specific ones.

File Backups

Backs up specified file directories, preserving your important files and configurations.

Compression

Compresses backups into tar.gz files to save space and make transfers more efficient.

Remote Storage

Supports uploading backups to FTP or SFTP servers for off-site storage.

Backup Rotation

Automatically manages backup retention, keeping only the specified number of recent backups.

Custom Commands

Executes custom commands at key points in the backup process for maximum flexibility.

Installation

# Clone the repository
git clone https://github.com/simo2409/backitup.git

# Install required packages
pip install pyyaml

# For SFTP support
pip install paramiko

# Make the script executable
chmod +x backitup.py

Usage

# Run with default config
./backitup.py

# Or specify a custom config file
./backitup.py /path/to/custom-config.yaml

Configure backitup using either a YAML configuration file, environment variables, or a combination of both.

Configuration

YAML Configuration
Environment Variables
# System Configuration
SYSTEM:
  server_name: "foobar.com"  # Server name to use in backup filenames

# Database Configuration
DB:
  db_type: "mysql"  # Can be "mysql" or "mariadb"
  db_host: "127.0.0.1"
  db_user: "root"  # Optional, defaults to "root"
  db_password: ""  # Optional, defaults to empty string
  db_name: "--all-databases"  # Optional, defaults to "--all-databases"

# Files Configuration
FILES:
  files_dir_path: "/var/www/something/current"

# Backup Destination Configuration
BACKUP:
  destination_type: "ftp"  # Can be "ftp", "sftp", or "local" (default)
  keep_local_copy: true    # Whether to keep a local copy after uploading
  keep_backups: 5          # Number of backups to preserve (older ones will be deleted)
# Set required environment variables
export BACKITUP_SERVER_NAME="foobar.com"
export BACKITUP_DB_TYPE="mysql"
export BACKITUP_DB_HOST="127.0.0.1"
export BACKITUP_FILES_DIR_PATH="/var/www/something/current"

# Set backup destination (optional)
export BACKITUP_DESTINATION_TYPE="ftp"
export BACKITUP_KEEP_LOCAL_COPY="true"
export BACKITUP_KEEP_BACKUPS="5"

# Run the backup agent
./backitup.py

Ready to Get Started?

Check out backitup on GitHub and start backing up your Linux servers today.