NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
anna_arun
Jul 23, 2014NETGEAR Expert
SQL DB Auto Backup
Any Inputs on how to do a SQL Data Base Backup automatically on scheduled basis (Free Software)
12 Replies
Replies have been turned off for this discussion
- chirpaLuminaryOn what model ReadyNAS?
- anna_arunNETGEAR ExpertRN314
- mdgm-ntgrNETGEAR Employee RetiredWell you could try to install something like MySQL Backup if you are comfortable with installing things via the shell or script your own backup via the shell.
- chirpaLuminaryWhoCares developer once made a MySQL Backup addon for the very old Sparc systems. Maybe something similar can be redone for OS6.
Similar request: viewtopic.php?f=153&t=76454 - fastfwdVirtuosoForgive me for asking, but I only use OS4... Doesn't OS6's MySQL package already include mysqldump?
- mh5blAspirantI think to use the Mysqldump with out a add-on, you have to have shell knowledge ?
I am still hope to get hold of a replacement add-on. to back-up my-sql databases. Would do it my-self but my knowledge is not good enough.
Anyone found one?
I am looking at this as a way to maybe go. installing it on the readyNAs website area - xeltrosApprenticeMysql dump is the way to go, not sure you can backup it automatically without shell, maybe phpmyadmin ? it lets you export the database, maybe it can schedule it (not sure).
Anyway via SQL this script was used to backup a GLPI server, it's a little old and I would advise to test it properly (though it worked perfectly for me).
I'm sorry, this was done for a french-only company so every comment is in french, I will comment if needed.
I deleted some stuff to present a clean script (it was backing up multiple databases and sending some alerts that wouldn't work on the NAS). I let you the part that saves the web files though.
the line that will help you is this one : mysqldump --user root --password=somepassword glpi > /Backups/GLPIDB/$NAME
it is saving the GLPI base as an SQL file named according to the stored value in the $NAME variable.
As already said, since the script was edited and is pretty old, you would want to test it on fake data (or with a fresh backup before testing).#!/bin/bash
#on teste si les dossiers existent
if [ ! -d /Backups/GLPIDB/ ]
then mkdir -p /Backups/GLPIDB
fi
if [ ! -d /Backups/GLPI-Files/ ]
then mkdir -p /Backups/GLPI-Files
fi
#On regarde si le log existe, si oui on supprime
if [ -e /scripts/GLPI-Backup.err ]
then rm /scripts/GLPI-Backup.err
fi
#on verifie qu'il reste de la place sur le serveur
DFREE=`df /|awk '{print $3}'|grep [0-9]`
DNEED1=`du /Backups -bc|awk '{print $1}'|tail -n 1`
DNEED=`echo "$DNEED1/4/1024"|bc`
if (( $DFREE < $DNEED ))
then
echo "Espace disque serveur GLPI [critique]" >> /scripts/GLPI-Backup.err
fi
#
#
#sauvegarde de la base GLPI
NAME=`date +"%d-%m-%y_%Hh%M"`_GLPIDB.sql
[color=#FF0000]mysqldump --user root --password=somepassword glpi > /Backups/GLPIDB/$NAME[/color]
RETURN=`echo $?`
# si OK suppression des anciens backups
if [ $RETURN = 0 ]
then
find /Backups/GLPIDB/*.sql -mtime +5 -exec rm {} \;
fi
#SI echec alors log
if [ $RETURN != 0 ]
then
echo "Sauvegarde de la base GLPI [ECHEC]" >> /scripts/GLPI-Backup.err
fi
#si deux backups sont crees dans la meme minute, le plus vieux est efface
if [ -e /Backups/GLPIDB/$NAME.bz2 ]
then rm /Backups/GLPIDB/$NAME.bz2
fi
#compression
bzip2 /Backups/GLPIDB/$NAME
FILESIZE=`du -b /Backups/GLPIDB/$NAME.bz2|awk '{print $1}'`
#on verifie que le fichier n'est pas vide (taille > 1.5M), sinon on log
if (( $FILESIZE < 1500000 ))
then
echo "Compression de la sauvegarde GLPI [ECHEC]" >> /scripts/GLPI-Backup.err
fi
#test de l'archive
bzip2 --test /Backups/GLPIDB/$NAME.bz2
RETURN=`echo $?`
#si le teste echoue ou que le fichier est trop petit on log
if [ $RETURN != 0 ]||(( $FILESIZE < 1500000 ))
then
echo "Test de la sauvegarde GLPI [ECHEC]" >> /scripts/GLPI-Backup.err
fi
#sauvegarde des documents GLPI
tar cjf /Backups/GLPI-Files/`date +"%d-%m-%y_%Hh%m"`_GLPI-FILES.tar.bz2 /var/www/html/glpi/files
RETURN=`echo $?`
#si Echec, on log
if [ $RETURN != 0 ]
then
echo "Sauvegarde des Fichiers GLPI [ECHEC]" >> /scripts/GLPI-Backup.err
fi - mh5blAspirantI am looking at this site 'www.mysqldumper.de'
looks like it may have promess.
but I think the readynas cut-down web-server my need additional files.
will keep you up-dates - mh5blAspirantSo I install this on the readynas. but there was a problem with the install and I have been told to
Check your php error log. This might be caused by missing the php-mysql extension in your php installation. - I have the add-on PHP by Poussin ( Thanks ) but does this include the php-mysql extension ?
- And how do I check the php error Logs ?
Thanks - xeltrosApprenticeI don't think that this is included. You can try apt-get install php5-mysql or you can install phpmyadmin from the web interface, I think it uses it to connect to mysql. Maybe the MySQL package installs it too. But installing those packages from the web interface will add some other unnecessary things too.
Related Content
NETGEAR Academy

Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!