A comprehensive backup and restore utility for Odoo instances
Project description
Odoo Backup Manager
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-manager.git
cd odoo-backup-manager
# 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-manager
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 settingsconnections.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 dumpfilestore.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_restoreflag (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
-
Missing PostgreSQL tools
- Install PostgreSQL client tools for your system
- Ensure
pg_dump,pg_restore, andpsqlare in PATH
-
Permission denied errors
- Ensure the user has read access to filestore directory
- Ensure the user has write access to backup directory
-
GUI not launching
- Install tkinter:
sudo apt-get install python3-tk
- Install tkinter:
-
SSH connection failures
- Verify SSH credentials and connectivity
- Check if SSH key has proper permissions (600)
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Run tests and ensure code quality
- Submit a pull request
License
MIT License - see LICENSE file for details
Support
- GitHub Issues: https://github.com/yourusername/odoo-backup-tool/issues
- Documentation: https://github.com/yourusername/odoo-backup-tool/wiki
Credits
Developed for the Odoo community to simplify backup and restore operations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file odoo_backup_manager-1.0.1.tar.gz.
File metadata
- Download URL: odoo_backup_manager-1.0.1.tar.gz
- Upload date:
- Size: 46.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ecb69aac6b00646bb6edb2a3af78517a2a08497f7f32c922d341257c1e5cc3b
|
|
| MD5 |
6bb67130a969ed63b528099234584f78
|
|
| BLAKE2b-256 |
9e4cd2fc616651b83217c541988bdf7f2a35496dd95180e640fa0664a0a473c7
|
File details
Details for the file odoo_backup_manager-1.0.1-py3-none-any.whl.
File metadata
- Download URL: odoo_backup_manager-1.0.1-py3-none-any.whl
- Upload date:
- Size: 50.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28f901bc5f254d6fa2fe5091599b3756d661e1f937aca0732a01dcef14f3ea39
|
|
| MD5 |
f82a1755b56b73dfaf6e3d064e38d9b0
|
|
| BLAKE2b-256 |
a02bf4b8a04822a65ddc3a387f81ed9cf28386f166a3f410572f6c272448c561
|