%define name smeserver-automysqlbackup %define version 3.0.RC6 %define release 11 %define rpmver 3.0.RC6 epoch: 2 Summary: automysqlbackup is a script to backup your msql database on sme8 Name: %{name} Version: %{version} Release: %{release}%{?dist} License: GPL Group: /Web/Application Source: %{name}-%{version}.tar.gz URL: http://sourceforge.net/projects/automysqlbackup/ BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot BuildArchitectures: noarch Requires: e-smith-base, e-smith-release >= 9 Requires: pax Requires: automysqlbackup BuildRequires: e-smith-devtools Patch0: smeserver-automysqlbackup-AdjustableCronJob.patch Patch1: smeserver-automysqlbackup-enhanced-templates.patch Patch2: smeserver-automysqlbackup-fix-runmysql.patch Patch3: smeserver-automysqlbackup-update-permission-change.patch %description This RPM is an unofficial addon for the SME Server 9.x. The target audience is the Linux/E-smith administrator who wants to backup their mysql databases with an automatic way. This script is based on automysqlbackup V3.0 %changelog * Mon Nov 26 2018 John Crisp 3.0.RC6-11.sme - fix runmysqlscript to allow for change in Backupdir key [SME: 10655] * Mon Nov 26 2018 John Crisp 3.0.RC6-10.sme - fix runmysqlbackup to allow for new databases [SME: 10654] * Fri Jul 06 2018 John Crisp 3.0.RC6-9.sme - Template configuration files - run automysqlbackup per conf directly from cron rather than runmysqlbackup - Add extra DB keys for mysql53, mysql55, mysql57 * Sun Apr 02 2017 stephane de Labrusse 3.0.RC6-8.sme - Added smeserver-automysqlbackup-AdjustableCronJob.patch - The time to run the Job is adjustable * Wed Sep 16 2015 stephane de Labrusse 3.0.RC6-6.sme - Added 'epoch: 2' * Sat Aug 22 2015 stephane de Labrusse 3.0.RC6-5.sme - Initial release to contribs9 * Sun Aug 17 2014 Stephane de Labrusse 3.0.RC6-4 - added my own patch against the --events warning --Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. * Sun Oct 27 2013 Stephane de Labrusse 3.0.RC6.3 - split the contrib in two versions smeserver-automysqlbackup and automysqlbackup * Mon Apr 22 2013 Stephane de Labrusse - [3.0.RC6] version Based on automysqlbackup V3.0 RC6 * Mon Apr 08 2013 Stephane de Labrusse - [0.01] Initial version Based on automysqlbackup V3.0 RC6 %prep rm -rf $RPM_BUILD_ROOT %setup %patch0 -p1 %patch1 -p1 %patch2 -p1 %patch3 -p1 %build perl createlinks %install /bin/rm -rf $RPM_BUILD_ROOT (cd root ;/usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) /bin/rm -f %{name}-%{version}-filelist /sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ --file /sbin/e-smith/runmysqlbackup 'attr(0750,root,root)' \ > %{name}-%{version}-filelist %files -f %{name}-%{version}-filelist %defattr(-,root,root) %clean rm -rf $RPM_BUILD_ROOT %pre %post SMEDB=automysqlbackup MYSQLUSER=backupuser # Expland template /etc/e-smith/events/actions/initialize-default-databases /sbin/e-smith/expand-template /etc/cron.d/runmysqlbackup echo "***********************************************************************" echo " " echo "Creating backup user for default mysql53 database" #create backupuser and give rights MYSQLPASS=$(/sbin/e-smith/config getprop $SMEDB DbPassword) mysql -e " GRANT EVENT,SELECT,LOCK TABLES ON *.* TO $MYSQLUSER@'localhost' " mysql -u root -e "SET PASSWORD FOR $MYSQLUSER@localhost = PASSWORD( '$MYSQLPASS' ) " mysqladmin flush-privileges /etc/rc.d/init.d/mysql.init start echo "done" echo "*** If you add mysql55/mysql57 you must add a backup user ***" echo "You can use the password from config show automysqlbackup" echo "e.g.: " echo "mysql55 -e \" GRANT EVENT,SELECT,LOCK TABLES ON *.* TO $MYSQLUSER@\'localhost\' \" " echo "mysql55 -u root -e \"SET PASSWORD FOR $MYSQLUSER@localhost = PASSWORD( \'$MYSQLPASS\' ) \" " echo " " echo "***********************************************************************" #protect the backup folder chmod -R 700 /root/backup/db %preun %postun if [ $1 = 0 ] ; then SMEDB=automysqlbackup MYSQLUSER=backupuser echo "=======================================================================" echo " " echo " delete mysql user and revoke all permissions" # This section deletes backupuser mysql -u root -e "REVOKE ALL PRIVILEGES ON *.* FROM '$MYSQLUSER'@'localhost';" mysql -u root -e "DROP USER $MYSQLUSER@localhost;" echo " " echo "Do that for each DB - e.g mysq55, mysql57 etc" echo " " # Delete custom template fragment echo " delete db configuration automysqlbackup" echo " " echo "=======================================================================" /sbin/e-smith/config delete $SMEDB fi