Jump to content
soana

[Beta] BackupSQL docker

13 posts in this topic Last Reply

Recommended Posts

I created this little docker to keep a backup of my SQL database for Kodi.

It starts from a phusion base image, installs mariaDB and then launches a cron job.

It requires a location for the backed-up files, cron parameters, IP address of the SQL server, the pushbullet token if you want notifications and the number of backup files to keep. All of these are environment variables and can be input after selecting Advanced view.

 

I'm using it for some time now with no issues.

Link to the docker-template is in my signature.

 

EDIT 1: Right now only one backup a day is supported due to the naming convention of the backup file. But then I was not expecting to need more than one backup a day.

 

EDIT 2: Obviously this docker needs more error proofing - I would like to change it into beta until all the fixes are in place

 

EDIT 3: Added variable for userid, implementing the password is giving me a little headache. Pushbullet notification modified for successful backup and to show error code if the backup command failed.

 

EDIT4: In order to restore a backed-up file use:

gunzip < MyDatabase_DATE.sql.gz | mysql -uroot -h 192.168.99.99

 

 

Share this post


Link to post

I love the idea of this, I set it up like this, my MySQL server is Needo's MariaDB

 

MySQLIP: 192.168.1.1 (also tried 192.168.1.1:3306)

 

The job runs but creates a 1kb file.

 

The logs don't reveal anything and the pushbullet notification suggests the backup is completed, I suspect it's because of a username / password issue as I don't see anywhere to input this.

 

Also, I think it would be helpful for people like me that aren't particularly skilled with mysql to let us know how to restore the data.

 

Share this post


Link to post

Agreed the userid and password fields need to be available for input.

Will update

 

 

Share this post


Link to post

Agreed the userid and password fields need to be available for input.

Will update

 

Look forward to it, now how would I go about reimporting the sql files into my MariaDB container?

Share this post


Link to post

EDIT 3: implementing the password is giving me a little headache.

 

Any progress on this?

Share this post


Link to post

i m not sure how much a docker repo eats resource but i dont think that mysql backup needs a docker repo. plugin sounds more efficiant to me. i edit my v5 plugin files a bit to backup my kodi database on mariadb docker and add pushover notification. i dont have time for updating my plugin to v6 but i will attach my files, soana or anyone can use or develop.

 

- extract files to /boot/custom/

- change the parametrs in cfg file.

- add /backup path mapping to your (mysql/mariadb etc)docker repo.

- and add this to your go file:

#mysql backup cron job
/boot/custom/mysql_cron.sh

* checking files permissions will be good to be sure they can be executed.

mysql.zip

Share this post


Link to post

I agree that a plugin makes more sense since it will also give the option/interface for restoring a backup.

The docker created will do regular backups but for restoring one has to use a command line.

 

 

 

Share this post


Link to post

For some reason docker exec -ti command throws a tty error when running from cron.

I remove -ti parameter, seems running ok now.

mysql.zip

Share this post


Link to post

I am getting the 1kb file also.  I saw where to enter the SQL_userid variable to which I entered 'root'.  What about the root password and/or db user and password?  Where how do I enter those?  Would love to get this working.  For years I used a script via cronjob to backup my Kodi db's, but now that I switched over to Docker containers I haven't been able to get anything to work.

 

Also, when working correctly, is this just the video database or does it also include the music database?

Share this post


Link to post

I can verify that the missing password is the problem.  I took took the command from your cronjob and added -p<apssword> and it ran as exepected from shell.  I would fix it, but I have no idea how to use github or how to make my own files to create a Docker container for unraid.

Share this post


Link to post

You can use my scripts 3 posts up, no docker needed.

 

I didn't realize  what your attachment was.  Thanks for the heads up.

Share this post


Link to post

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.