Last active
February 12, 2026 00:34
-
-
Save lionslair/19f526e960d851c2a51c84f677b06d81 to your computer and use it in GitHub Desktop.
gets rid of all useless inserts in downloaded sql dumps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Check if the script received an argument | |
| if [ "$#" -ne 1 ]; then | |
| echo "Usage: $0 <sql_file>" | |
| exit 1 | |
| fi | |
| # Check if the file exists | |
| if [ ! -f "$1" ]; then | |
| echo "File not found!" | |
| exit 1 | |
| fi | |
| # Remove the insert statements | |
| sed -i.bak \ | |
| -e '/INSERT INTO `sessions`/d' \ | |
| -e '/INSERT INTO `pulse_aggregates`/d' \ | |
| -e '/INSERT INTO `pulse_entries`/d' \ | |
| -e '/INSERT INTO `pulse_values`/d' \ | |
| -e '/INSERT INTO `failed_jobs`/d' \ | |
| -e '/INSERT INTO `queue_failed_jobs`/d' \ | |
| -e '/INSERT INTO `xero_tokens`/d' \ | |
| -e '/INSERT INTO `daily_task_statuses`/d' \ | |
| -e '/INSERT INTO `logs`/d' \ | |
| -e '/INSERT INTO `app_logs`/d' \ | |
| -e '/INSERT INTO `subcontractor_driver_messages`/d' \ | |
| -e '/INSERT INTO `business_central_sync_logs`/d' \ | |
| -e '/INSERT INTO `activity_logs`/d' \ | |
| -e '/^CREATE DATABASE /Id' \ | |
| -e '/^USE /Id' \ | |
| -e 's/DEFINER=[^*]*\*/\*/' \ | |
| -e 's/DEFINER=[^ ]* //' \ | |
| "$1" | |
| echo "Operation completed. The original file was backed up with a .bak extension." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment