1 |
unnilennium |
1.1 |
%define name smeserver-automysqlbackup |
2 |
stephdl |
1.2 |
%define version 3.0.RC6 |
3 |
jpp |
1.8 |
%define release 12 |
4 |
unnilennium |
1.1 |
%define rpmver 3.0.RC6 |
5 |
|
|
|
6 |
stephdl |
1.3 |
epoch: 2 |
7 |
unnilennium |
1.1 |
Summary: automysqlbackup is a script to backup your msql database on sme8 |
8 |
|
|
Name: %{name} |
9 |
|
|
Version: %{version} |
10 |
|
|
Release: %{release}%{?dist} |
11 |
|
|
License: GPL |
12 |
|
|
Group: /Web/Application |
13 |
|
|
Source: %{name}-%{version}.tar.gz |
14 |
|
|
URL: http://sourceforge.net/projects/automysqlbackup/ |
15 |
|
|
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot |
16 |
|
|
BuildArchitectures: noarch |
17 |
stephdl |
1.4 |
Requires: e-smith-base, e-smith-release >= 9 |
18 |
unnilennium |
1.1 |
Requires: pax |
19 |
|
|
Requires: automysqlbackup |
20 |
|
|
BuildRequires: e-smith-devtools |
21 |
stephdl |
1.4 |
Patch0: smeserver-automysqlbackup-AdjustableCronJob.patch |
22 |
jcrisp |
1.5 |
Patch1: smeserver-automysqlbackup-enhanced-templates.patch |
23 |
jcrisp |
1.6 |
Patch2: smeserver-automysqlbackup-fix-runmysql.patch |
24 |
jcrisp |
1.7 |
Patch3: smeserver-automysqlbackup-update-permission-change.patch |
25 |
jpp |
1.8 |
Patch4: smeserver-automysqlbackup-3.0.RC6-bz10806.errorsAndCreateUsers.patch |
26 |
jcrisp |
1.6 |
|
27 |
unnilennium |
1.1 |
%description |
28 |
stephdl |
1.4 |
This RPM is an unofficial addon for the SME Server 9.x. |
29 |
unnilennium |
1.1 |
The target audience is the Linux/E-smith administrator |
30 |
|
|
who wants to backup their mysql databases with an automatic way. |
31 |
|
|
This script is based on automysqlbackup V3.0 |
32 |
|
|
|
33 |
|
|
|
34 |
|
|
|
35 |
|
|
%changelog |
36 |
jpp |
1.8 |
* Sun Sep 22 2019 Jean-Philipe Pialasse <tests@pialasse.com> 3.0.RC6-12.sme |
37 |
|
|
- fix multiple cause of error noise and performance [SME: 10806] |
38 |
|
|
* avoid parallel run of all backups, cron template rewritten |
39 |
|
|
* avoid multiple parallel or repeated chmod and chown |
40 |
|
|
* protect from undesired chmod or chown |
41 |
|
|
* consistent use of status for cron and conf templates |
42 |
|
|
* create backup user for mysql, mysql55 and mysql57 (Maria to do) |
43 |
|
|
* update mysql53 use to mysql51 as variable |
44 |
|
|
* migrate fragment to remove Mysql55 Mysql57 Mymaria Mysql53 if Mysql53 exist |
45 |
|
|
* remove default value in db for Mysql55 Mysql57 Mymaria Mysql53 |
46 |
|
|
* default as enabled in fragments for all automysql My* properties |
47 |
|
|
- create default user in dbs [SME: 10808] |
48 |
|
|
|
49 |
jcrisp |
1.7 |
* Mon Nov 26 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 3.0.RC6-11.sme |
50 |
|
|
- fix runmysqlscript to allow for change in Backupdir key [SME: 10655] |
51 |
|
|
|
52 |
jcrisp |
1.6 |
* Mon Nov 26 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 3.0.RC6-10.sme |
53 |
jcrisp |
1.7 |
- fix runmysqlbackup to allow for new databases [SME: 10654] |
54 |
jcrisp |
1.6 |
|
55 |
jcrisp |
1.5 |
* Fri Jul 06 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 3.0.RC6-9.sme |
56 |
|
|
- Template configuration files |
57 |
|
|
- run automysqlbackup per conf directly from cron rather than runmysqlbackup |
58 |
|
|
- Add extra DB keys for mysql53, mysql55, mysql57 |
59 |
|
|
|
60 |
stephdl |
1.4 |
* Sun Apr 02 2017 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-8.sme |
61 |
|
|
- Added smeserver-automysqlbackup-AdjustableCronJob.patch |
62 |
|
|
- The time to run the Job is adjustable |
63 |
|
|
|
64 |
stephdl |
1.3 |
* Wed Sep 16 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-6.sme |
65 |
|
|
- Added 'epoch: 2' |
66 |
|
|
|
67 |
stephdl |
1.2 |
* Sat Aug 22 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-5.sme |
68 |
|
|
- Initial release to contribs9 |
69 |
|
|
|
70 |
|
|
* Sun Aug 17 2014 Stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-4 |
71 |
|
|
- added my own patch against the --events warning |
72 |
|
|
--Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. |
73 |
unnilennium |
1.1 |
|
74 |
|
|
* Sun Oct 27 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6.3 |
75 |
|
|
- split the contrib in two versions smeserver-automysqlbackup and automysqlbackup |
76 |
|
|
* Mon Apr 22 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> |
77 |
|
|
- [3.0.RC6] version Based on automysqlbackup V3.0 RC6 |
78 |
|
|
* Mon Apr 08 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> |
79 |
|
|
- [0.01] Initial version Based on automysqlbackup V3.0 RC6 |
80 |
|
|
|
81 |
|
|
%prep |
82 |
|
|
rm -rf $RPM_BUILD_ROOT |
83 |
|
|
|
84 |
|
|
%setup |
85 |
stephdl |
1.4 |
%patch0 -p1 |
86 |
jcrisp |
1.5 |
%patch1 -p1 |
87 |
jcrisp |
1.6 |
%patch2 -p1 |
88 |
jcrisp |
1.7 |
%patch3 -p1 |
89 |
jpp |
1.8 |
%patch4 -p1 |
90 |
unnilennium |
1.1 |
|
91 |
|
|
%build |
92 |
stephdl |
1.4 |
perl createlinks |
93 |
unnilennium |
1.1 |
|
94 |
|
|
%install |
95 |
|
|
/bin/rm -rf $RPM_BUILD_ROOT |
96 |
stephdl |
1.2 |
(cd root ;/usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) |
97 |
unnilennium |
1.1 |
/bin/rm -f %{name}-%{version}-filelist |
98 |
stephdl |
1.4 |
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ |
99 |
|
|
--file /sbin/e-smith/runmysqlbackup 'attr(0750,root,root)' \ |
100 |
|
|
> %{name}-%{version}-filelist |
101 |
unnilennium |
1.1 |
|
102 |
|
|
|
103 |
|
|
%files -f %{name}-%{version}-filelist |
104 |
|
|
|
105 |
|
|
%defattr(-,root,root) |
106 |
|
|
|
107 |
|
|
%clean |
108 |
|
|
rm -rf $RPM_BUILD_ROOT |
109 |
|
|
|
110 |
|
|
%pre |
111 |
|
|
|
112 |
|
|
%post |
113 |
|
|
SMEDB=automysqlbackup |
114 |
|
|
MYSQLUSER=backupuser |
115 |
|
|
# Expland template |
116 |
|
|
/etc/e-smith/events/actions/initialize-default-databases |
117 |
stephdl |
1.4 |
/sbin/e-smith/expand-template /etc/cron.d/runmysqlbackup |
118 |
unnilennium |
1.1 |
|
119 |
jcrisp |
1.5 |
echo "***********************************************************************" |
120 |
|
|
echo " " |
121 |
|
|
echo "Creating backup user for default mysql53 database" |
122 |
unnilennium |
1.1 |
#create backupuser and give rights |
123 |
|
|
MYSQLPASS=$(/sbin/e-smith/config getprop $SMEDB DbPassword) |
124 |
stephdl |
1.2 |
mysql -e " GRANT EVENT,SELECT,LOCK TABLES ON *.* TO $MYSQLUSER@'localhost' " |
125 |
unnilennium |
1.1 |
mysql -u root -e "SET PASSWORD FOR $MYSQLUSER@localhost = PASSWORD( '$MYSQLPASS' ) " |
126 |
|
|
mysqladmin flush-privileges |
127 |
|
|
/etc/rc.d/init.d/mysql.init start |
128 |
jcrisp |
1.5 |
echo "done" |
129 |
|
|
echo "*** If you add mysql55/mysql57 you must add a backup user ***" |
130 |
|
|
echo "You can use the password from config show automysqlbackup" |
131 |
|
|
echo "e.g.: " |
132 |
|
|
echo "mysql55 -e \" GRANT EVENT,SELECT,LOCK TABLES ON *.* TO $MYSQLUSER@\'localhost\' \" " |
133 |
|
|
echo "mysql55 -u root -e \"SET PASSWORD FOR $MYSQLUSER@localhost = PASSWORD( \'$MYSQLPASS\' ) \" " |
134 |
|
|
echo " " |
135 |
|
|
echo "***********************************************************************" |
136 |
unnilennium |
1.1 |
|
137 |
|
|
#protect the backup folder |
138 |
|
|
chmod -R 700 /root/backup/db |
139 |
|
|
|
140 |
|
|
%preun |
141 |
|
|
%postun |
142 |
|
|
if [ $1 = 0 ] ; then |
143 |
|
|
SMEDB=automysqlbackup |
144 |
|
|
MYSQLUSER=backupuser |
145 |
|
|
echo "=======================================================================" |
146 |
jcrisp |
1.5 |
echo " " |
147 |
|
|
echo " delete mysql user and revoke all permissions" |
148 |
unnilennium |
1.1 |
# This section deletes backupuser |
149 |
|
|
mysql -u root -e "REVOKE ALL PRIVILEGES ON *.* FROM '$MYSQLUSER'@'localhost';" |
150 |
|
|
mysql -u root -e "DROP USER $MYSQLUSER@localhost;" |
151 |
|
|
echo " " |
152 |
jcrisp |
1.5 |
echo "Do that for each DB - e.g mysq55, mysql57 etc" |
153 |
|
|
echo " " |
154 |
unnilennium |
1.1 |
# Delete custom template fragment |
155 |
|
|
echo " delete db configuration automysqlbackup" |
156 |
jcrisp |
1.5 |
echo " " |
157 |
unnilennium |
1.1 |
echo "=======================================================================" |
158 |
|
|
|
159 |
|
|
/sbin/e-smith/config delete $SMEDB |
160 |
|
|
fi |