Backup MySQL Database
Pay $1.00 for 1,000 Backups
This Actor may be unreliable while under maintenance. Would you like to try a similar Actor instead?
See alternative ActorsBackup MySQL Database
Pay $1.00 for 1,000 Backups
This actor connects to a MySQL database, and generates a complete database backup. The output can be saved in JSON or SQL format and is uploaded to the Apify key-value store for easy access. Simply provide the database connection details to get started.
MySQL Database Dump Actor
A private Apify actor that creates backups of MySQL databases and stores them in either JSON or SQL format. This actor connects to your MySQL database, dumps all tables, and saves the output to both a local file and the Apify key-value store.
Features
- Dumps all tables from a specified MySQL database
- Supports both JSON and SQL output formats
- Automatically escapes special characters in SQL output
- Saves dumps both locally and to Apify key-value store
- Handles large datasets efficiently
- Provides detailed logging throughout the process
Input Parameters
The actor accepts the following input parameters:
Parameter | Type | Required | Description |
---|---|---|---|
host | string | Yes | MySQL database host address |
user | string | Yes | MySQL database username |
password | string | Yes | MySQL database password |
database | string | Yes | Name of the database to dump |
outputFormat | string | No | Output format ('json' or 'sql'). Defaults to 'sql' |
Usage
- Create a new task in your Apify account
- Set up input parameters:
1{ 2 "host": "your-database-host", 3 "user": "your-username", 4 "password": "your-password", 5 "database": "your-database-name", 6 "outputFormat": "sql" 7}
- Run the actor
Output
The actor produces two outputs:
- A local file named
mysql_dump.[json|sql]
- A record in the Apify key-value store with the key
MYSQL_DUMP
JSON Format Example
1{ 2 "table1": [ 3 { 4 "id": 1, 5 "name": "Example", 6 "value": 100 7 } 8 ], 9 "table2": [ 10 ... 11 ] 12}
SQL Format Example
1-- Dumping data for table: users 2INSERT INTO `users` (id, name, email) VALUES 3(1, 'John Doe', 'john@example.com'), 4(2, 'Jane Smith', 'jane@example.com');
Dependencies
apify
: Apify SDK for Node.jsmysql2
: MySQL client for Node.jsfs
: Node.js file system modulepath
: Node.js path module
Technical Details
The actor performs the following steps:
- Initializes the Apify environment
- Connects to the specified MySQL database
- Retrieves a list of all tables
- Dumps data from each table
- Converts the data to the specified format (JSON or SQL)
- Saves the dump locally and to Apify storage
- Closes the database connection
- Exits gracefully
Error Handling
The actor includes error handling for:
- Missing input parameters
- Database connection issues
- Data retrieval errors
- File system operations
Limitations
- Large databases may require increased memory allocation
- Binary data types are not fully supported
- Table structures (CREATE TABLE statements) are not included in SQL dumps
Proprietary Notice
This is a private, proprietary software. All rights reserved. This actor, its source code, and documentation are confidential and proprietary to the owner. No part of this software may be reproduced, distributed, or transmitted in any form or by any means without the prior written permission of the owner.
Security Notice
This actor contains sensitive database operations. Please ensure:
- Keep all credentials secure
- Limit access to authorized personnel only
- Regularly rotate database credentials
- Monitor usage logs for unauthorized access
Actor Metrics
1 monthly user
-
1 star
>99% runs succeeded
Created in Jan 2025
Modified 7 minutes ago