### Complete Production Backup Example Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt A comprehensive example showing a production-ready backup configuration with all recommended options. ```APIDOC ## Complete Production Backup Example ### Description A comprehensive example showing a production-ready backup configuration with all recommended options. ### Method POST ### Endpoint /mysqldump ### Parameters #### Query Parameters - **database** (string) - Required - The name of the production database to dump. - **resultFile** (string) - Required - The path to save the compressed dump file. - **host** (string) - Required - The database host (can be set via environment variable DB_HOST). - **port** (number) - Optional - The database port (default: 3306, can be set via environment variable DB_PORT). - **user** (string) - Required - The database user (can be set via environment variable DB_USER). - **password** (string) - Required - The database password (can be set via environment variable DB_PASSWORD). - **singleTransaction** (boolean) - Optional - Enables dumping within a single transaction for consistency. - **skipLockTables** (boolean) - Optional - Skips table locking when `singleTransaction` is enabled. - **routines** (boolean) - Optional - Includes stored routines (procedures and functions) in the dump. - **triggers** (boolean) - Optional - Includes triggers in the dump. - **events** (boolean) - Optional - Includes scheduled events in the dump. - **skipCreateOptions** (boolean) - Optional - Omits MySQL-specific CREATE TABLE options. - **skipAddDropTable** (boolean) - Optional - Omits DROP TABLE IF EXISTS statements. - **addDropTrigger** (boolean) - Optional - Includes DROP TRIGGER statements. - **hexBlob** (boolean) - Optional - Dumps binary data as hex for safer transfer. - **compress** (boolean) - Optional - Compresses the output file using gzip. - **ignoreTable** (array of strings) - Optional - An array of table names to exclude from the dump. - **log** (boolean) - Optional - Enables logging of stdout/stderr from the mysqldump process. ### Request Example (Conceptual - actual execution via script) ```javascript // This is a conceptual representation of the parameters used in a script. // The actual API call would be a POST request with these parameters. await mysqldump({ // Connection database: 'production_db', resultFile: '/var/backups/mysql/production_YYYY-MM-DDTHH-MM-SS.sql', host: process.env.DB_HOST || 'localhost', port: parseInt(process.env.DB_PORT || '3306'), user: process.env.DB_USER || 'backup_user', password: process.env.DB_PASSWORD || '', // Consistency singleTransaction: true, skipLockTables: true, // Include all objects routines: true, triggers: true, events: true, // Output formatting skipCreateOptions: false, skipAddDropTable: false, addDropTrigger: true, hexBlob: true, // Compression compress: true, // Exclude temporary/cache tables ignoreTable: ['sessions', 'cache', 'job_batches', 'failed_jobs'], // Debugging log: true }); ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the backup completion and location. #### Response Example ```json { "message": "Backup completed: /var/backups/mysql/production_YYYY-MM-DDTHH-MM-SS.sql.gz" } ``` ``` -------------------------------- ### Install mysqldump-wrapper using npm Source: https://github.com/shinchven/mysqldump-wrapper/blob/master/README.MD This command installs the mysqldump-wrapper package. Ensure you have Node.js and npm installed. The package also has a dependency on the MySQL client (`mysql-client`) which needs to be installed separately on your operating system. ```bash npm install mysqldump-wrapper ``` -------------------------------- ### Complete Production-Ready MySQL Backup Example Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt This comprehensive example showcases a production-ready backup configuration using mysqldump-wrapper. It includes settings for database connection, consistency, output formatting, compression, table exclusion, and logging, demonstrating a robust backup strategy. Dependencies include 'mysqldump-wrapper' and 'path'. ```typescript import mysqldump from 'mysqldump-wrapper'; import path from 'path'; const createProductionBackup = async () => { const timestamp = new Date().toISOString().replace(/[:.]/g, '-'); const backupPath = path.join('/var/backups/mysql', `production_${timestamp}.sql`); try { await mysqldump({ // Connection database: 'production_db', resultFile: backupPath, host: process.env.DB_HOST || 'localhost', port: parseInt(process.env.DB_PORT || '3306'), user: process.env.DB_USER || 'backup_user', password: process.env.DB_PASSWORD || '', // Consistency singleTransaction: true, skipLockTables: true, // Include all objects routines: true, triggers: true, events: true, // Output formatting skipCreateOptions: false, skipAddDropTable: false, addDropTrigger: true, hexBlob: true, // Compression compress: true, // Exclude temporary/cache tables ignoreTable: ['sessions', 'cache', 'job_batches', 'failed_jobs'], // Debugging log: true }); console.log(`Backup completed: ${backupPath}.gz`); return `${backupPath}.gz`; } catch (error) { console.error('Backup failed:', error); throw error; } }; createProductionBackup(); ``` -------------------------------- ### Basic Mysqldump with Node.js Source: https://github.com/shinchven/mysqldump-wrapper/blob/master/README.MD Demonstrates the basic usage of the mysqldump function in Node.js, requiring essential connection and output parameters. ```typescript const args = { database: 'mydb', resultFile: 'dump.sql', host: 'localhost', port: 3306, user: 'root', password: 'password', }; await mysqldump(args); ``` -------------------------------- ### mysqldump(args) - Basic Usage Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt The main function to execute a MySQL database dump. It takes a configuration object and returns a Promise that resolves on success or rejects on error. ```APIDOC ## POST /api/mysqldump ### Description Executes a MySQL database dump with the specified configuration options. Constructs the appropriate mysqldump command from the provided arguments and executes it as a child process. ### Method POST ### Endpoint /api/mysqldump ### Parameters #### Request Body - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The path to the output file for the dump. - **host** (string) - Required - The MySQL server hostname. - **port** (number) - Required - The MySQL server port. - **user** (string) - Required - The MySQL username. - **password** (string) - Required - The MySQL password. - **mysqldumpPath** (string) - Optional - Custom path to the mysqldump binary. - **tables** (array) - Optional - An array of table names to include in the dump. - **ignoreTable** (array) - Optional - An array of table names to exclude from the dump. - **where** (string) - Optional - A WHERE clause to filter rows for specific tables. - **noData** (boolean) - Optional - If true, dumps schema only, without data. - **routines** (boolean) - Optional - If true, includes stored procedures and functions. - **triggers** (boolean) - Optional - If true, includes triggers. - **events** (boolean) - Optional - If true, includes scheduled events. ### Request Example ```json { "database": "my_application_db", "resultFile": "/backups/my_application_db.sql", "host": "localhost", "port": 3306, "user": "backup_user", "password": "secure_password_123" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of successful dump completion. #### Response Example ```json { "message": "Database dump completed successfully" } ``` ``` -------------------------------- ### Mysqldump Wrapper - Connection Configuration Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Details on the required parameters for establishing a MySQL connection for the database dump. ```APIDOC ## POST /api/mysqldump/connection ### Description Configures and executes a MySQL database dump using provided connection details. ### Method POST ### Endpoint /api/mysqldump/connection ### Parameters #### Request Body - **database** (string) - Required - Database name to dump. - **resultFile** (string) - Required - Output file path for the dump. - **host** (string) - Required - MySQL server hostname. - **port** (number) - Required - MySQL server port. - **user** (string) - Required - MySQL username. - **password** (string) - Required - MySQL password. - **mysqldumpPath** (string) - Optional - Custom path to the mysqldump binary. ### Request Example ```json { "database": "ecommerce_db", "resultFile": "./backup/dump.sql", "host": "db.example.com", "port": 3306, "user": "admin", "password": "admin_password", "mysqldumpPath": "/usr/local/mysql/bin/mysqldump" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of successful dump completion. #### Response Example ```json { "message": "Database dump completed successfully with provided connection details." } ``` ``` -------------------------------- ### Configure Output Formatting for MySQL Dumps Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt This snippet demonstrates how to configure the output format of SQL dump files using mysqldump-wrapper. It shows options for creating human-readable dumps with complete INSERT statements and compact dumps for storage efficiency. Dependencies include the 'mysqldump-wrapper' library. ```typescript import mysqldump from 'mysqldump-wrapper'; // Human-readable dump with complete inserts await mysqldump({ database: 'my_database', resultFile: './backup/readable_dump.sql', host: 'localhost', port: 3306, user: 'root', password: 'rootpass', skipExtendedInsert: true, // One INSERT per row (more readable) completeInsert: true, // Include column names in INSERT skipCreateOptions: false, // Keep MySQL-specific CREATE options skipAddDropTable: false, // Include DROP TABLE IF EXISTS addDropTrigger: true, // Include DROP TRIGGER statements skipComments: false // Keep comments in output }); // Compact dump for storage efficiency await mysqldump({ database: 'my_database', resultFile: './backup/compact_dump.sql', host: 'localhost', port: 3306, user: 'root', password: 'rootpass', compact: true, // Minimal output format skipComments: true // Remove all comments }); ``` -------------------------------- ### Enable Gzip Compression for MySQL Dump Files Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt This snippet shows how to automatically compress MySQL dump files using gzip after the backup process completes, leveraging the 'compress' option in mysqldump-wrapper. It also includes options for transactional consistency and hex-encoding binary data. Dependencies include the 'mysqldump-wrapper' library. ```typescript import mysqldump from 'mysqldump-wrapper'; await mysqldump({ database: 'large_database', resultFile: './backup/large_db_dump.sql', host: 'localhost', port: 3306, user: 'admin', password: 'admin_password', compress: true, // Result: large_db_dump.sql.gz singleTransaction: true, hexBlob: true // Dump binary data as hex (safer) }); ``` -------------------------------- ### Configure MySQL Connection for Dump - TypeScript Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Sets up the connection parameters for a MySQL database dump. Includes required fields like database name, output file, host, port, user, and password. Optionally allows specifying a custom mysqldump binary path. ```typescript import mysqldump from 'mysqldump-wrapper'; await mysqldump({ // Required connection parameters database: 'ecommerce_db', // Database name to dump resultFile: './backup/dump.sql', // Output file path host: 'db.example.com', // MySQL server hostname port: 3306, // MySQL server port user: 'admin', // MySQL username password: 'admin_password', // MySQL password // Optional: custom mysqldump binary path mysqldumpPath: '/usr/local/mysql/bin/mysqldump' }); ``` -------------------------------- ### Output Formatting Options Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Configure how the SQL dump file is formatted, controlling INSERT statements, DROP TABLE statements, and other output characteristics. ```APIDOC ## Output Formatting Options ### Description Configure how the SQL dump file is formatted, controlling INSERT statements, DROP TABLE statements, and other output characteristics. ### Method POST ### Endpoint /mysqldump ### Parameters #### Query Parameters - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The path to save the dump file. - **host** (string) - Required - The database host. - **port** (number) - Optional - The database port (default: 3306). - **user** (string) - Required - The database user. - **password** (string) - Required - The database password. - **skipExtendedInsert** (boolean) - Optional - If true, uses one INSERT per row (more readable). - **completeInsert** (boolean) - Optional - If true, includes column names in INSERT statements. - **skipCreateOptions** (boolean) - Optional - If true, omits MySQL-specific CREATE options. - **skipAddDropTable** (boolean) - Optional - If true, omits DROP TABLE IF EXISTS statements. - **addDropTrigger** (boolean) - Optional - If true, includes DROP TRIGGER statements. - **skipComments** (boolean) - Optional - If true, removes comments from the output. - **compact** (boolean) - Optional - If true, uses a minimal output format. ### Request Example ```json { "database": "my_database", "resultFile": "./backup/readable_dump.sql", "host": "localhost", "port": 3306, "user": "root", "password": "rootpass", "skipExtendedInsert": true, "completeInsert": true, "skipCreateOptions": false, "skipAddDropTable": false, "addDropTrigger": true, "skipComments": false } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message that the dump was created. #### Response Example ```json { "message": "Dump created successfully at ./backup/readable_dump.sql" } ``` ``` -------------------------------- ### Mysqldump with Custom Node.js Options Source: https://github.com/shinchven/mysqldump-wrapper/blob/master/README.MD Illustrates how to use the mysqldump function with custom options to modify the database dump process, including skipping table options and enabling compression. ```typescript const args = { database: 'mydb', resultFile: 'dump.sql', host: 'localhost', port: 3306, user: 'root', password: 'password', skipCreateOptions: true, skipAddDropTable: false, completeInsert: true, compress: true, }; await mysqldump(args); ``` -------------------------------- ### Basic Database Dump with mysqldump-wrapper Source: https://github.com/shinchven/mysqldump-wrapper/blob/master/README.MD This TypeScript code snippet demonstrates how to use the mysqldump-wrapper to export a MySQL database. It configures essential parameters like database name, output file, host, port, user, and password. The function is asynchronous and includes basic error handling. ```typescript import mysqldump from 'mysqldump-wrapper'; const args = { database: 'your_database_name', resultFile: 'dump.sql', host: 'localhost', port: 3306, user: 'your_username', password: 'your_password', // ...other options }; (async () => { try { await mysqldump(args); console.log('Database dumped successfully.'); } catch (error) { console.error('Error dumping the database:', error); } })(); ``` -------------------------------- ### Compression Support Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Automatically compress the dump file using gzip after the dump completes. ```APIDOC ## Compression Support ### Description Automatically compress the dump file using gzip after the dump completes. ### Method POST ### Endpoint /mysqldump ### Parameters #### Query Parameters - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The path to save the dump file (will be appended with `.gz` if compression is enabled). - **host** (string) - Required - The database host. - **port** (number) - Optional - The database port (default: 3306). - **user** (string) - Required - The database user. - **password** (string) - Required - The database password. - **compress** (boolean) - Optional - If true, compress the output file using gzip. - **singleTransaction** (boolean) - Optional - If true, dumps the database within a single transaction. - **hexBlob** (boolean) - Optional - If true, dumps binary data as hex (safer). ### Request Example ```json { "database": "large_database", "resultFile": "./backup/large_db_dump.sql", "host": "localhost", "port": 3306, "user": "admin", "password": "admin_password", "compress": true, "singleTransaction": true, "hexBlob": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message that the dump was created and compressed. #### Response Example ```json { "message": "Dump created and compressed successfully at ./backup/large_db_dump.sql.gz" } ``` ``` -------------------------------- ### Perform Dry Runs and Enable Logging for MySQL Dumps Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt This snippet demonstrates debugging capabilities within mysqldump-wrapper, including performing a 'dry run' to generate the mysqldump command without execution and enabling logging to view stdout/stderr from the mysqldump process. Dependencies include the 'mysqldump-wrapper' library. ```typescript import mysqldump from 'mysqldump-wrapper'; // Dry run - prints command without executing await mysqldump({ database: 'test_db', resultFile: './test_dump.sql', host: 'localhost', port: 3306, user: 'test_user', password: 'test_pass', runDry: true, // Only print command, don't execute tables: ['users', 'products'], singleTransaction: true }); // Output: mysqldump "test_db" --result-file="./test_dump.sql" --host="localhost" --port=3306 --user="test_user" --password="test_pass" --skip-create-options --skip-add-drop-table --single-transaction users products // Enable logging for executed commands await mysqldump({ database: 'test_db', resultFile: './test_dump.sql', host: 'localhost', port: 3306, user: 'test_user', password: 'test_pass', log: true // Print stdout/stderr from mysqldump }); ``` -------------------------------- ### mysqldump function configuration Source: https://github.com/shinchven/mysqldump-wrapper/blob/master/README.MD Details the configuration object required to execute a database dump using the mysqldump-wrapper. ```APIDOC ## mysqldump(options) ### Description Executes a MySQL database dump based on the provided configuration object. ### Method Function Call ### Parameters #### Request Body (Options Object) - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The file path where the SQL dump will be saved. - **host** (string) - Required - The MySQL host address. - **port** (number) - Required - The MySQL port. - **user** (string) - Required - MySQL username. - **password** (string) - Required - MySQL password. - **compress** (boolean) - Optional - If true, compresses the output using Gzip. - **tables** (string[]) - Optional - Array of specific tables to include. - **where** (string) - Optional - SQL WHERE clause to filter rows. - **singleTransaction** (boolean) - Optional - If true, performs the dump in a single transaction. ### Request Example { "database": "mydb", "resultFile": "dump.sql", "host": "localhost", "port": 3306, "user": "root", "password": "password", "compress": true } ### Response #### Success Response (Promise) - **void** - Resolves when the dump process completes successfully. ``` -------------------------------- ### Execute Basic Database Dump - TypeScript Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Performs a basic database dump using the mysqldump-wrapper library. Requires connection details and a result file path. Handles errors during the dump process. ```typescript import mysqldump from 'mysqldump-wrapper'; // Basic database dump const basicDump = async () => { try { await mysqldump({ database: 'my_application_db', resultFile: '/backups/my_application_db.sql', host: 'localhost', port: 3306, user: 'backup_user', password: 'secure_password_123' }); console.log('Database dump completed successfully'); } catch (error) { console.error('Database dump failed:', error.message); } }; basicDump(); ``` -------------------------------- ### Mysqldump Wrapper - Schema-Only Dump Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt How to perform a dump that includes only the database structure (schema) without any data. ```APIDOC ## POST /api/mysqldump/schema-only ### Description Executes a MySQL database dump that exports only the database structure (schema) without including any data. ### Method POST ### Endpoint /api/mysqldump/schema-only ### Parameters #### Request Body - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The path to the output file for the schema dump. - **host** (string) - Required - The MySQL server hostname. - **port** (number) - Required - The MySQL server port. - **user** (string) - Required - The MySQL username. - **password** (string) - Required - The MySQL password. - **noData** (boolean) - Required - Set to `true` to perform a schema-only dump. - **routines** (boolean) - Optional - If true, includes stored procedures and functions in the schema. - **triggers** (boolean) - Optional - If true, includes triggers in the schema. - **events** (boolean) - Optional - If true, includes scheduled events in the schema. ### Request Example ```json { "database": "production_db", "resultFile": "./schema/database_structure.sql", "host": "localhost", "port": 3306, "user": "admin", "password": "admin_pass", "noData": true, "routines": true, "triggers": true, "events": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of successful schema-only dump completion. #### Response Example ```json { "message": "Schema-only database dump completed successfully." } ``` ``` -------------------------------- ### Select and Filter Tables for Dump - TypeScript Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Demonstrates how to control table inclusion and exclusion during a database dump. Supports dumping specific tables, ignoring certain tables, or filtering rows using a WHERE clause. ```typescript import mysqldump from 'mysqldump-wrapper'; // Dump only specific tables await mysqldump({ database: 'ecommerce_db', resultFile: './backup/orders_backup.sql', host: 'localhost', port: 3306, user: 'backup_user', password: 'password123', tables: ['orders', 'order_items', 'customers'] // Only these tables }); // Dump all tables except specified ones await mysqldump({ database: 'ecommerce_db', resultFile: './backup/partial_backup.sql', host: 'localhost', port: 3306, user: 'backup_user', password: 'password123', ignoreTable: ['sessions', 'cache', 'logs'] // Exclude these tables }); // Filter rows with WHERE clause await mysqldump({ database: 'ecommerce_db', resultFile: './backup/recent_orders.sql', host: 'localhost', port: 3306, user: 'backup_user', password: 'password123', tables: ['orders'], where: 'created_at > "2024-01-01"' // Only orders from 2024 }); ``` -------------------------------- ### Mysqldump Wrapper - Table Selection and Filtering Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Options for selecting specific tables or excluding others, and filtering rows using a WHERE clause. ```APIDOC ## POST /api/mysqldump/filter ### Description Performs a MySQL database dump with options to include only specific tables, exclude certain tables, or filter rows based on a WHERE clause. ### Method POST ### Endpoint /api/mysqldump/filter ### Parameters #### Request Body - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The path to the output file for the dump. - **host** (string) - Required - The MySQL server hostname. - **port** (number) - Required - The MySQL server port. - **user** (string) - Required - The MySQL username. - **password** (string) - Required - The MySQL password. - **tables** (array) - Optional - An array of table names to include in the dump. - **ignoreTable** (array) - Optional - An array of table names to exclude from the dump. - **where** (string) - Optional - A WHERE clause to filter rows for specific tables. ### Request Example (Specific Tables) ```json { "database": "ecommerce_db", "resultFile": "./backup/orders_backup.sql", "host": "localhost", "port": 3306, "user": "backup_user", "password": "password123", "tables": ["orders", "order_items", "customers"] } ``` ### Request Example (Exclude Tables) ```json { "database": "ecommerce_db", "resultFile": "./backup/partial_backup.sql", "host": "localhost", "port": 3306, "user": "backup_user", "password": "password123", "ignoreTable": ["sessions", "cache", "logs"] } ``` ### Request Example (Filter Rows) ```json { "database": "ecommerce_db", "resultFile": "./backup/recent_orders.sql", "host": "localhost", "port": 3306, "user": "backup_user", "password": "password123", "tables": ["orders"], "where": "created_at > \"2024-01-01\"" } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message of successful dump completion. #### Response Example ```json { "message": "Database dump completed with specified table filters." } ``` ``` -------------------------------- ### Debugging and Dry Run Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Test command generation without executing the actual dump, useful for debugging and verification. ```APIDOC ## Debugging and Dry Run ### Description Test command generation without executing the actual dump, useful for debugging and verification. ### Method POST ### Endpoint /mysqldump ### Parameters #### Query Parameters - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The path to save the dump file. - **host** (string) - Required - The database host. - **port** (number) - Optional - The database port (default: 3306). - **user** (string) - Required - The database user. - **password** (string) - Required - The database password. - **runDry** (boolean) - Optional - If true, prints the mysqldump command without executing it. - **tables** (array of strings) - Optional - An array of table names to include in the dump. - **singleTransaction** (boolean) - Optional - If true, dumps the database within a single transaction. - **log** (boolean) - Optional - If true, prints stdout/stderr from the mysqldump process. ### Request Example (Dry Run) ```json { "database": "test_db", "resultFile": "./test_dump.sql", "host": "localhost", "port": 3306, "user": "test_user", "password": "test_pass", "runDry": true, "tables": ["users", "products"], "singleTransaction": true } ``` ### Response (Dry Run Example Output) ``` mysqldump "test_db" --result-file="./test_dump.sql" --host="localhost" --port=3306 --user="test_user" --password="test_pass" --skip-create-options --skip-add-drop-table --single-transaction users products ``` ### Request Example (Logging) ```json { "database": "test_db", "resultFile": "./test_dump.sql", "host": "localhost", "port": 3306, "user": "test_user", "password": "test_pass", "log": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message indicating the dry run command or logging output. #### Response Example ```json { "message": "mysqldump command generated successfully." } ``` ``` -------------------------------- ### Transaction and Locking Options Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Control how the dump handles table locking and transactions for data consistency during the backup process. ```APIDOC ## Transaction and Locking Options ### Description Control how the dump handles table locking and transactions for data consistency during the backup process. ### Method POST ### Endpoint /mysqldump ### Parameters #### Query Parameters - **database** (string) - Required - The name of the database to dump. - **resultFile** (string) - Required - The path to save the dump file. - **host** (string) - Required - The database host. - **port** (number) - Optional - The database port (default: 3306). - **user** (string) - Required - The database user. - **password** (string) - Required - The database password. - **singleTransaction** (boolean) - Optional - If true, dumps the database within a single transaction (recommended for InnoDB). - **skipLockTables** (boolean) - Optional - If true, skips locking tables (use with `singleTransaction`). - **skipDisableKeys** (boolean) - Optional - If true, skips disabling keys during the dump. - **skipAddLocks** (boolean) - Optional - If true, skips adding LOCK TABLES statements. ### Request Example ```json { "database": "transactional_db", "resultFile": "./backup/consistent_dump.sql", "host": "localhost", "port": 3306, "user": "backup_user", "password": "password", "singleTransaction": true, "skipLockTables": true, "skipDisableKeys": true, "skipAddLocks": true } ``` ### Response #### Success Response (200) - **message** (string) - Confirmation message that the dump was created. #### Response Example ```json { "message": "Dump created successfully at ./backup/consistent_dump.sql" } ``` ``` -------------------------------- ### Control Transactions and Locking for Consistent MySQL Dumps Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt This snippet illustrates how to manage table locking and transactions for data consistency during MySQL backups using mysqldump-wrapper. It focuses on using a single transaction, which is recommended for InnoDB tables, and disabling table locks for a consistent dump. Dependencies include the 'mysqldump-wrapper' library. ```typescript import mysqldump from 'mysqldump-wrapper'; // Consistent dump using single transaction (recommended for InnoDB) await mysqldump({ database: 'transactional_db', resultFile: './backup/consistent_dump.sql', host: 'localhost', port: 3306, user: 'backup_user', password: 'password', singleTransaction: true, // Dump in single transaction skipLockTables: true, // Don't lock tables (use with singleTransaction) skipDisableKeys: true, // Don't disable keys during dump skipAddLocks: true // Don't add LOCK TABLES statements }); ``` -------------------------------- ### Perform Schema-Only Database Dump - TypeScript Source: https://context7.com/shinchven/mysqldump-wrapper/llms.txt Exports only the database structure without any data. This is useful for creating database templates or documenting the schema. Includes options to include routines, triggers, and events. ```typescript import mysqldump from 'mysqldump-wrapper'; await mysqldump({ database: 'production_db', resultFile: './schema/database_structure.sql', host: 'localhost', port: 3306, user: 'admin', password: 'admin_pass', noData: true, // Dump structure only, no data routines: true, // Include stored procedures and functions triggers: true, // Include triggers events: true // Include scheduled events }); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.