Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

mariadb backup script fails with "Note /usr/bin/mysql: unknown option '-m'"

Featured Replies

A while backup a user on Reddit gave me this script that I use in User Scripts to backup my mariadb database instances.

 

I tried it today for the first time because I'm about to update my containers, and it's failing.

 

Here is the script:

#!/bin/bash

# Check if array is started
ls /mnt/disk[1-9]* 1>/dev/null 2>/dev/null
if [ $? -ne 0 ]
then
   echo "ERROR:  Array must be started before using this script"
   exit
fi

BACKUP_DIR="/mnt/user/backups/SQL/mariadb"
 
mkdir -p "$BACKUP_DIR"


databases=`docker exec mariadb /usr/bin/mysql -rootuser -password -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema|mysql)"`


for db in $databases; do

    echo "Backing up $db"
    mkdir -p "$BACKUP_DIR/$db"

    FOLDER=$BACKUP_DIR/$db
    mkdir -p $FOLDER
    FILENAME=$(date +%Y-%m-%d-%H.%M.%S).sql
    FILEPATH=$FOLDER/$FILENAME
    docker exec mariadb /usr/bin/mysqldump -u rootuser --password=****** $db > $FILEPATH
    tar czf $FILEPATH.tgz -C $FOLDER $FILENAME
    rm $FILEPATH

done


find $BACKUP_DIR/ -type f -name '*.tgz' -mtime +7 -exec rm {} \;

 

The only parts he asked me to edit were the password and username parts, other than that, I changed the BACKUP_DIR variable, I gave it a new proper location.

 

Notes, I checked via CLI, in /usr/bin, there is no "mysql" there so.. I don't know why

 

Please guide me! :D

Solved by Kilrah

  • Community Expert
  • Solution

Is your mariadb container actually called "mariadb"?

 

Theres a "db-backup" app in CA that can do the job more cleanly.

  • Author
32 minutes ago, Kilrah said:

Is your mariadb container actually called "mariadb"?

 

Theres a "db-backup" app in CA that can do the job more cleanly.

db-backup, ok thank you I'll look.

Yes my container is called "mariadb"

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.