https://github.com/genaker/magento-dump
Python Magento Dump Script
https://github.com/genaker/magento-dump
Last synced: 4 months ago
JSON representation
Python Magento Dump Script
- Host: GitHub
- URL: https://github.com/genaker/magento-dump
- Owner: Genaker
- Created: 2025-02-21T08:29:40.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-02-25T02:15:03.000Z (over 1 year ago)
- Last Synced: 2025-04-21T14:09:24.776Z (about 1 year ago)
- Language: Python
- Size: 25.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Magento Database Management Tool
A powerful Python script to list Magento database tables and perform MySQL dumps with filtering and compression.
# Features
✅ Show Table Sizes: Lists only tables larger than 1MB, sorted by size.
✅ Dump Full Database: Dumps all tables, ignoring predefined ones.
✅ Interactive CLI: Select options using an interactive menu.
✅ Progress Tracking: Shows real-time progress during MySQL dump.
✅ Config Auto-Detection: Reads Magento env.php for database settings.
✅ Compression: Dumps are gzip compressed for storage efficiency.
# Installation
1. Clone the Repository
```
git clone https://github.com/yourusername/magento-db-tool.git
cd magento-db-tool
```
2. Install Dependencies
```
pip install tqdm simple-term-menu
```
🔹 Run Interactive CLI
```
python3 magento_db_tool.py
```
🔹 Show Tables Bigger Than 1MB
```
python3 magento_db_tool.py show-tables
```
🔹 Dump Entire Magento Database
```
python3 magento_db_tool.py db-dump
```
📝 Commands Overview
Command Description
- show-tables List tables larger than 1MB with row count & size
- db-dump Dumps all tables with gzip compression
- exit Close the tool
📦 Example Output
Listing Tables
🔍 Fetching table details (only tables > 1MB)...
```
Table Name Rows Size (MB)
=================================================================
sales_order 50000 15.6
catalog_product_entity 120000 12.3
customer_entity 30000 8.4
```
✅ Showing 3 tables larger than 1MB.
Dumping Database
```
🚀 Starting database dump...
📂 Dumping table: sales_order ...
📂 Dumping table: catalog_product_entity ...
📂 Dumping table: customer_entity ...
✅ Database dump successful: magento_luma_dump_20240219.sql.gz
```
🔧 Configuration
This tool automatically extracts your Magento database settings from app/etc/env.php. No manual setup required!
Change ignored tables in ignore_tables inside the script.
⏱ Automate with CRON
To schedule daily database backups at midnight, add this to crontab -e:
```
0 0 * * * /usr/bin/python3 /path/to/magento_db_tool.py db-dump
```
## Deploy to PyPI, follow these steps:
1️. Install Twine (if not installed)
```
pip install twine
```
2️. Build the Package
Inside your project root (magento-dump/):
```
pip install --upgrade setuptools
python setup.py sdist bdist_wheel
```
3️. Upload to PyPI
```
twine upload dist/*
```
or
```
rm -rf dist/ && python setup.py sdist bdist_wheel && twine upload dist/*
```
or new wey:
```
pip install build
rm -rf dist/*
python -m build
pip install twine
twine upload dist/*
```
This will ask for your PyPI credentials. Once uploaded, you can install your package with:
```
pip install magento-dump
```
📜 License
MIT License. Free to use and modify.