How call mysqldump (MariaDB) from user scripts?


Recommended Posts

I do have MariaDB running in a docker container. I would like to take a backup of all databases every night with the help of the user scripts plugin. Whatever I try, it doesn't work.

 

This is the last iteration of my tests. If I call it from the console it works perfect. Running from user scripts fails:

docker exec mariadb /usr/bin/mysqldump --user=root --password=******** nextcloud > /mnt/user/data/mariadb_backup/nextcloud/dump.sql

Here's the complete MariaDB/Nextcloud backup script with the failing line:

 

#!/bin/bash
#arrayStarted=true
#clearLog=true
#noParity=true

docker stop nextcloud
docker stop mariadb

rsync -avPX --delete-during /mnt/cache/system/appdata/mariadb/ /mnt/user/data/appdata_backup/mariadb/

rsync -avPX --delete-during /mnt/cache/system/appdata/nextcloud/ /mnt/user/data/appdata_backup/nextcloud/

rsync -avPX --delete-during /mnt/cache/NextCloud/ /mnt/user/data/nextcloud_backup/

rsync -avPX --delete-during /mnt/cache/NextCloud/hawi/files/.Contacts-Backup/ /mnt/user/data/nextcloud/contacts/

docker start mariadb
docker start nextcloud

# Does not work
# docker exec mariadb /usr/bin/mysqldump --user=root --password=******** nextcloud > /mnt/user/data/mariadb_backup/nextcloud/dump.sql

 

I even tried to but "sudo" in front of it - no joy. I'm out of ideas. Is there really no way to take a backup of a MariaDB database with user scripts?

 

Many thanks in advance.

 

Link to comment

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.