Skip to main content

A comprehensive backup and restore utility for Odoo instances

Project description

Odoo Backup Tool

A comprehensive backup and restore utility for Odoo instances, supporting both database and filestore operations with local and remote (SSH) connections.

Features

  • ๐Ÿ—„๏ธ Complete Backup & Restore: Handles both PostgreSQL database and Odoo filestore
  • ๐Ÿ”’ Secure Storage: Encrypted password storage for connection profiles
  • ๐ŸŒ Remote Support: Backup/restore from remote servers via SSH
  • ๐Ÿ’พ Connection Profiles: Save and reuse connection configurations
  • ๐Ÿ–ฅ๏ธ Dual Interface: Both CLI and GUI interfaces available
  • ๐Ÿ“ฆ Archive Management: Creates compressed archives with metadata
  • ๐Ÿ”„ Flexible Operations: Backup only, restore only, or backup & restore in one operation
  • ๐Ÿ›ก๏ธ Production Protection: Prevent accidental restores to production databases with allow_restore flag

Installation

From Source

# Clone the repository
git clone https://github.com/jpsteil/odoo-backup-tool.git
cd odoo-backup-tool

# Install the package
pip install -e .

# Or install with GUI support
pip install -e ".[gui]"

# For development
pip install -r requirements-dev.txt

Using pip

pip install odoo-backup-tool

Prerequisites

  • Python 3.8 or higher
  • PostgreSQL client tools (pg_dump, pg_restore, psql)
  • tar command-line utility
  • tkinter (for GUI mode) - usually included with Python

Installing PostgreSQL Client Tools

Ubuntu/Debian

sudo apt-get update
sudo apt-get install postgresql-client

RHEL/CentOS/Fedora

sudo dnf install postgresql

macOS

brew install postgresql

Usage

Command Line Interface

Basic Backup

# Backup database and filestore
odoo-backup backup --name mydb --host localhost --user odoo --filestore /var/lib/odoo/filestore

# Backup database only
odoo-backup backup --name mydb --host localhost --user odoo --no-filestore

# Backup with specific output directory
odoo-backup backup --name mydb --host localhost --user odoo --output-dir /backups

Basic Restore

# Restore from backup file
odoo-backup restore --file backup_MYDB_20240101_120000.tar.gz --name newdb --host localhost --user odoo

# Restore database only (skip filestore)
odoo-backup restore --file backup.tar.gz --name newdb --host localhost --user odoo --no-filestore

Connection Management

# List saved connections
odoo-backup connections list

# Save a new connection (protected by default)
odoo-backup connections save --name prod --host db.example.com --user odoo --database mydb --filestore /var/lib/odoo

# Save a development connection with restore allowed
odoo-backup connections save --name dev --host localhost --user odoo --database devdb --filestore /var/lib/odoo --allow-restore

# Test a connection
odoo-backup connections test prod

# Delete a connection
odoo-backup connections delete prod

Using Saved Connections

# Backup using saved connection
odoo-backup backup --connection prod --name mydb

# Restore using saved connection
odoo-backup restore --connection dev --file backup.tar.gz --name restored_db

From Odoo Configuration File

# Parse odoo.conf and create backup
odoo-backup from-config /etc/odoo/odoo.conf --backup

Graphical User Interface

Launch the GUI:

# Using the command
odoo-backup gui

# Or using the dedicated launcher
odoo-backup-gui

The GUI provides:

  • Visual connection management
  • Backup/restore operations with progress tracking
  • Connection testing
  • Backup file management
  • Operation logs

Configuration

The tool stores its configuration in ~/.config/odoo_backup_tool/:

  • config.json: Application settings
  • connections.db: Encrypted connection profiles

Default Configuration

{
  "backup_dir": "~/odoo_backups",
  "default_odoo_version": "17.0",
  "pg_dump_options": ["--no-owner", "--no-acl"],
  "compression_level": 6,
  "max_backup_age_days": 30,
  "auto_cleanup": false,
  "verbose": false
}

Backup File Structure

Backup archives contain:

  • database.sql: PostgreSQL database dump
  • filestore.tar.gz: Compressed filestore data (if included)
  • metadata.json: Backup metadata (timestamp, database name, Odoo version)

Security

  • Passwords are encrypted using machine-specific keys
  • SSH connections support both password and key-based authentication
  • No passwords are stored in plain text
  • Production database protection with allow_restore flag (defaults to False)
    • Connections are protected from restore operations by default
    • Must explicitly enable restore capability for non-production databases
    • GUI filters destination connections based on allow_restore setting
    • CLI validates allow_restore before executing restore operations

Development

Project Structure

odoo_backup_tool/
โ”œโ”€โ”€ odoo_backup_tool/
โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”œโ”€โ”€ cli.py              # CLI entry point
โ”‚   โ”œโ”€โ”€ gui_launcher.py     # GUI launcher
โ”‚   โ”œโ”€โ”€ core/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ backup_restore.py  # Core backup/restore logic
โ”‚   โ”œโ”€โ”€ db/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ connection_manager.py  # Connection management
โ”‚   โ”œโ”€โ”€ gui/
โ”‚   โ”‚   โ”œโ”€โ”€ __init__.py
โ”‚   โ”‚   โ””โ”€โ”€ main_window.py  # GUI implementation
โ”‚   โ””โ”€โ”€ utils/
โ”‚       โ”œโ”€โ”€ __init__.py
โ”‚       โ””โ”€โ”€ config.py       # Configuration management
โ”œโ”€โ”€ tests/                  # Test suite
โ”œโ”€โ”€ setup.py               # Package setup
โ”œโ”€โ”€ requirements.txt       # Production dependencies
โ”œโ”€โ”€ requirements-dev.txt   # Development dependencies
โ””โ”€โ”€ README.md

Running Tests

# Run all tests
pytest

# Run with coverage
pytest --cov=odoo_backup_tool

# Run specific test file
pytest tests/test_backup_restore.py

Code Formatting

# Format code with black
black odoo_backup_tool/

# Check code style
flake8 odoo_backup_tool/

# Type checking
mypy odoo_backup_tool/

Troubleshooting

Common Issues

  1. Missing PostgreSQL tools

    • Install PostgreSQL client tools for your system
    • Ensure pg_dump, pg_restore, and psql are in PATH
  2. Permission denied errors

    • Ensure the user has read access to filestore directory
    • Ensure the user has write access to backup directory
  3. GUI not launching

    • Install tkinter: sudo apt-get install python3-tk
  4. SSH connection failures

    • Verify SSH credentials and connectivity
    • Check if SSH key has proper permissions (600)

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests and ensure code quality
  5. Submit a pull request

License

MIT License - see LICENSE file for details

Support

Credits

Developed for the Odoo community to simplify backup and restore operations.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

odoo_backup_manager-1.0.0.tar.gz (46.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

odoo_backup_manager-1.0.0-py3-none-any.whl (50.3 kB view details)

Uploaded Python 3

File details

Details for the file odoo_backup_manager-1.0.0.tar.gz.

File metadata

  • Download URL: odoo_backup_manager-1.0.0.tar.gz
  • Upload date:
  • Size: 46.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.3

File hashes

Hashes for odoo_backup_manager-1.0.0.tar.gz
Algorithm Hash digest
SHA256 753de0d47ec93594feb612cd648588d949d5f67bd520fb13fc5023455b7a8bf7
MD5 8c7e54e1da427c41bf42cd5e6a5dd4b0
BLAKE2b-256 7bc5f94853f387af52db27c44c05ecd466bf33becb55ef34d2efef98f7004110

See more details on using hashes here.

File details

Details for the file odoo_backup_manager-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for odoo_backup_manager-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 21063f49f8d952558ac0f15efaafcd1c98f2097b42c0d7762a6e344220a01053
MD5 41b53cc554c03e76a436d70e152aeb4c
BLAKE2b-256 e4dab6dfe2a9b4061559931651db6517f9b2559698905866764c07a12ffc8dc3

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page