1 |
unnilennium |
1.1 |
%define name smeserver-automysqlbackup |
2 |
stephdl |
1.2 |
%define version 3.0.RC6 |
3 |
stephdl |
1.4 |
%define release 8 |
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 |
unnilennium |
1.1 |
%description |
23 |
stephdl |
1.4 |
This RPM is an unofficial addon for the SME Server 9.x. |
24 |
unnilennium |
1.1 |
The target audience is the Linux/E-smith administrator |
25 |
|
|
who wants to backup their mysql databases with an automatic way. |
26 |
|
|
This script is based on automysqlbackup V3.0 |
27 |
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
|
|
%changelog |
31 |
stephdl |
1.4 |
* Sun Apr 02 2017 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-8.sme |
32 |
|
|
- Added smeserver-automysqlbackup-AdjustableCronJob.patch |
33 |
|
|
- The time to run the Job is adjustable |
34 |
|
|
|
35 |
stephdl |
1.3 |
* Wed Sep 16 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-6.sme |
36 |
|
|
- Added 'epoch: 2' |
37 |
|
|
|
38 |
stephdl |
1.2 |
* Sat Aug 22 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-5.sme |
39 |
|
|
- Initial release to contribs9 |
40 |
|
|
|
41 |
|
|
* Sun Aug 17 2014 Stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-4 |
42 |
|
|
- added my own patch against the --events warning |
43 |
|
|
--Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. |
44 |
unnilennium |
1.1 |
|
45 |
|
|
* Sun Oct 27 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6.3 |
46 |
|
|
- split the contrib in two versions smeserver-automysqlbackup and automysqlbackup |
47 |
|
|
* Mon Apr 22 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> |
48 |
|
|
- [3.0.RC6] version Based on automysqlbackup V3.0 RC6 |
49 |
|
|
* Mon Apr 08 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> |
50 |
|
|
- [0.01] Initial version Based on automysqlbackup V3.0 RC6 |
51 |
|
|
|
52 |
|
|
%prep |
53 |
|
|
rm -rf $RPM_BUILD_ROOT |
54 |
|
|
|
55 |
|
|
%setup |
56 |
stephdl |
1.4 |
%patch0 -p1 |
57 |
unnilennium |
1.1 |
|
58 |
|
|
%build |
59 |
stephdl |
1.4 |
perl createlinks |
60 |
unnilennium |
1.1 |
|
61 |
|
|
%install |
62 |
|
|
/bin/rm -rf $RPM_BUILD_ROOT |
63 |
stephdl |
1.2 |
(cd root ;/usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) |
64 |
unnilennium |
1.1 |
/bin/rm -f %{name}-%{version}-filelist |
65 |
stephdl |
1.4 |
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ |
66 |
|
|
--file /sbin/e-smith/runmysqlbackup 'attr(0750,root,root)' \ |
67 |
|
|
> %{name}-%{version}-filelist |
68 |
unnilennium |
1.1 |
|
69 |
|
|
|
70 |
|
|
%files -f %{name}-%{version}-filelist |
71 |
|
|
|
72 |
|
|
%defattr(-,root,root) |
73 |
|
|
|
74 |
|
|
%clean |
75 |
|
|
rm -rf $RPM_BUILD_ROOT |
76 |
|
|
|
77 |
|
|
%pre |
78 |
|
|
|
79 |
|
|
%post |
80 |
|
|
SMEDB=automysqlbackup |
81 |
|
|
MYSQLUSER=backupuser |
82 |
|
|
# Expland template |
83 |
|
|
/etc/e-smith/events/actions/initialize-default-databases |
84 |
stephdl |
1.4 |
/sbin/e-smith/expand-template /etc/cron.d/runmysqlbackup |
85 |
unnilennium |
1.1 |
|
86 |
|
|
#create backupuser and give rights |
87 |
|
|
MYSQLPASS=$(/sbin/e-smith/config getprop $SMEDB DbPassword) |
88 |
stephdl |
1.2 |
mysql -e " GRANT EVENT,SELECT,LOCK TABLES ON *.* TO $MYSQLUSER@'localhost' " |
89 |
unnilennium |
1.1 |
mysql -u root -e "SET PASSWORD FOR $MYSQLUSER@localhost = PASSWORD( '$MYSQLPASS' ) " |
90 |
|
|
mysqladmin flush-privileges |
91 |
|
|
/etc/rc.d/init.d/mysql.init start |
92 |
|
|
|
93 |
|
|
#protect the backup folder |
94 |
|
|
chmod -R 700 /root/backup/db |
95 |
|
|
|
96 |
|
|
%preun |
97 |
|
|
%postun |
98 |
|
|
if [ $1 = 0 ] ; then |
99 |
|
|
SMEDB=automysqlbackup |
100 |
|
|
MYSQLUSER=backupuser |
101 |
|
|
echo "=======================================================================" |
102 |
|
|
echo " delete mysql user and revoque all permissions" |
103 |
|
|
# This section deletes backupuser |
104 |
|
|
mysql -u root -e "REVOKE ALL PRIVILEGES ON *.* FROM '$MYSQLUSER'@'localhost';" |
105 |
|
|
mysql -u root -e "DROP USER $MYSQLUSER@localhost;" |
106 |
|
|
echo " " |
107 |
|
|
# Delete custom template fragment |
108 |
|
|
echo " delete db configuration automysqlbackup" |
109 |
|
|
echo "=======================================================================" |
110 |
|
|
|
111 |
|
|
/sbin/e-smith/config delete $SMEDB |
112 |
|
|
fi |