Last active
February 16, 2025 10:25
-
-
Save filipnet/527c51eccd5baa0140e888faffb2fc86 to your computer and use it in GitHub Desktop.
This script updates the deprecated MySQL commands used in the automysqlbackup tool to their MariaDB equivalents. It replaces mysqldump with mariadb-dump, mysqlshow with mariadb-show, and mysql with mariadb, ensuring compatibility with newer MariaDB installations. A timestamped backup of the original file is created before applying the changes, p…
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 | |
| # Script to update deprecated MySQL commands in the automysqlbackup file. | |
| # The automysqlbackup project can be found at: https://sourceforge.net/projects/automysqlbackup/ | |
| # | |
| # The following warnings have been observed when using automysqlbackup: | |
| # | |
| # mysqldump: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb-dump' instead | |
| # mysqlshow: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb-show' instead | |
| # mysql: Deprecated program name. It will be removed in a future release, use '/usr/bin/mariadb' instead | |
| # | |
| # This script will replace these deprecated commands with their MariaDB equivalents | |
| # and create a timestamped backup of the original file before making any changes. | |
| # It is intended to help users transition to using MariaDB tools for backups. | |
| # Path to the file that needs to be modified | |
| FILE="/usr/local/bin/automysqlbackup" | |
| # Check if the file exists | |
| if [[ ! -f "$FILE" ]]; then | |
| echo "Error: File $FILE not found!" | |
| exit 1 | |
| fi | |
| # Create a timestamped backup of the original file | |
| TIMESTAMP=$(date +"%Y%m%d%H%M%S") | |
| BACKUP_FILE="$FILE.backup.$TIMESTAMP" | |
| cp "$FILE" "$BACKUP_FILE" | |
| # Replace deprecated commands with the new ones | |
| sed -i 's/mysqldump/mariadb-dump/g' "$FILE" | |
| sed -i 's/mysqlshow/mariadb-show/g' "$FILE" | |
| # Replace only 'mysql' when it is followed by a space (to avoid replacing other instances) | |
| sed -i 's/\bmysql\b/mariadb/g' "$FILE" | |
| # Confirm the changes | |
| echo "The file $FILE has been updated. A backup was created at $BACKUP_FILE." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this Script.
The mysql sed is to heavy for me. It replaces ../mysql/... too. On Debian you can overwrite some variables, so I had to replace it too.
Here my changes on a Debian 11:
Thanks
Ulf