1 |
%define name smeserver-automysqlbackup |
%define name smeserver-automysqlbackup |
2 |
%define version 3.0.RC7 |
%define version 3.0.RC6 |
3 |
%define release 1 |
%define release 15 |
4 |
%define rpmver 3.0.RC6 |
%define rpmver 3.0.RC6 |
5 |
|
|
6 |
|
epoch: 2 |
7 |
Summary: automysqlbackup is a script to backup your msql database on sme8 |
Summary: automysqlbackup is a script to backup your msql database on sme8 |
8 |
Name: %{name} |
Name: %{name} |
9 |
Version: %{version} |
Version: %{version} |
14 |
URL: http://sourceforge.net/projects/automysqlbackup/ |
URL: http://sourceforge.net/projects/automysqlbackup/ |
15 |
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot |
BuildRoot: /var/tmp/%{name}-%{version}-%{release}-buildroot |
16 |
BuildArchitectures: noarch |
BuildArchitectures: noarch |
17 |
Requires: e-smith-base, e-smith-release >= 8 |
Requires: e-smith-base, e-smith-release >= 9 |
18 |
Requires: pax |
Requires: pax |
19 |
Requires: automysqlbackup |
Requires: automysqlbackup |
20 |
BuildRequires: e-smith-devtools |
BuildRequires: e-smith-devtools |
21 |
|
Patch0: smeserver-automysqlbackup-AdjustableCronJob.patch |
22 |
|
Patch1: smeserver-automysqlbackup-enhanced-templates.patch |
23 |
|
Patch2: smeserver-automysqlbackup-fix-runmysql.patch |
24 |
|
Patch3: smeserver-automysqlbackup-update-permission-change.patch |
25 |
|
Patch4: smeserver-automysqlbackup-3.0.RC6-bz10806.errorsAndCreateUsers.patch |
26 |
|
|
27 |
%description |
%description |
28 |
This RPM is an unofficial addon for the SME Server 8.x. |
This RPM is an unofficial addon for the SME Server 9.x. |
29 |
The target audience is the Linux/E-smith administrator |
The target audience is the Linux/E-smith administrator |
30 |
who wants to backup their mysql databases with an automatic way. |
who wants to backup their mysql databases with an automatic way. |
31 |
This script is based on automysqlbackup V3.0 |
This script is based on automysqlbackup V3.0 |
33 |
|
|
34 |
|
|
35 |
%changelog |
%changelog |
36 |
* Mon Jun 16 2014 JP Pialasse <tests@pialasse.com> 3.0.RC7-1.sme |
* Sun Sep 22 2019 Jean-Philipe Pialasse <tests@pialasse.com> 3.0.RC6-14.sme |
37 |
- initial import to SME9 contribs |
- 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 |
|
- tidy spec file |
49 |
|
|
50 |
|
* Mon Nov 26 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 3.0.RC6-11.sme |
51 |
|
- fix runmysqlscript to allow for change in Backupdir key [SME: 10655] |
52 |
|
|
53 |
|
* Mon Nov 26 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 3.0.RC6-10.sme |
54 |
|
- fix runmysqlbackup to allow for new databases [SME: 10654] |
55 |
|
|
56 |
|
* Fri Jul 06 2018 John Crisp <jcrisp@safeandsoundit.co.uk> 3.0.RC6-9.sme |
57 |
|
- Template configuration files |
58 |
|
- run automysqlbackup per conf directly from cron rather than runmysqlbackup |
59 |
|
- Add extra DB keys for mysql53, mysql55, mysql57 |
60 |
|
|
61 |
|
* Sun Apr 02 2017 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-8.sme |
62 |
|
- Added smeserver-automysqlbackup-AdjustableCronJob.patch |
63 |
|
- The time to run the Job is adjustable |
64 |
|
|
65 |
|
* Wed Sep 16 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-6.sme |
66 |
|
- Added 'epoch: 2' |
67 |
|
|
68 |
|
* Sat Aug 22 2015 stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-5.sme |
69 |
|
- Initial release to contribs9 |
70 |
|
|
71 |
|
* Sun Aug 17 2014 Stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6-4 |
72 |
|
- added my own patch against the --events warning |
73 |
|
--Warning: Skipping the data of table mysql.event. Specify the --events option explicitly. |
74 |
|
|
75 |
* Sun Oct 27 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6.3 |
* Sun Oct 27 2013 Stephane de Labrusse <stephdl@de-labrusse.fr> 3.0.RC6.3 |
76 |
- split the contrib in two versions smeserver-automysqlbackup and automysqlbackup |
- split the contrib in two versions smeserver-automysqlbackup and automysqlbackup |
83 |
rm -rf $RPM_BUILD_ROOT |
rm -rf $RPM_BUILD_ROOT |
84 |
|
|
85 |
%setup |
%setup |
86 |
|
%patch0 -p1 |
87 |
|
%patch1 -p1 |
88 |
|
%patch2 -p1 |
89 |
|
%patch3 -p1 |
90 |
|
%patch4 -p1 |
91 |
|
|
92 |
%build |
%build |
93 |
|
perl createlinks |
94 |
|
find . \( -name .gitinclude -o -name .gitignore \) -print0 | \ |
95 |
|
xargs -0 rm -f |
96 |
|
|
97 |
%install |
%install |
98 |
/bin/rm -rf $RPM_BUILD_ROOT |
/bin/rm -rf $RPM_BUILD_ROOT |
99 |
(/usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) |
(cd root ;/usr/bin/find . -depth -print | /bin/cpio -dump $RPM_BUILD_ROOT) |
100 |
/bin/rm -f %{name}-%{version}-filelist |
/bin/rm -f %{name}-%{version}-filelist |
101 |
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT > %{name}-%{version}-filelist |
/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ |
102 |
|
--file /sbin/e-smith/runmysqlbackup 'attr(0750,root,root)' \ |
103 |
|
--dir /root/backup 'attr(0700,root,root)' \ |
104 |
|
--dir /root/backup/db 'attr(0700,root,root)' \ |
105 |
|
--dir /root/backup/db/daily 'attr(0700,root,root)' \ |
106 |
|
--dir /root/backup/db/fullschema 'attr(0700,root,root)' \ |
107 |
|
--dir /root/backup/db/latest 'attr(0700,root,root)' \ |
108 |
|
--dir /root/backup/db/monthly 'attr(0700,root,root)' \ |
109 |
|
--dir /root/backup/db/status 'attr(0700,root,root)' \ |
110 |
|
--dir /root/backup/db/tmp 'attr(0700,root,root)' \ |
111 |
|
--dir /root/backup/db/weekly 'attr(0700,root,root)' \ |
112 |
|
> %{name}-%{version}-filelist |
113 |
|
|
114 |
|
|
115 |
%files -f %{name}-%{version}-filelist |
%files -f %{name}-%{version}-filelist |
122 |
%pre |
%pre |
123 |
|
|
124 |
%post |
%post |
|
SMEDB=automysqlbackup |
|
|
MYSQLUSER=backupuser |
|
|
# Expland template |
|
|
/etc/e-smith/events/actions/initialize-default-databases |
|
|
|
|
|
echo "=========================================================================================" |
|
|
echo " Your Databases are saved in /root/backup/db " |
|
|
echo " only Root can access to these folders" |
|
|
echo " a mail is send to Admin for all logs " |
|
|
echo " " |
|
|
echo " Configuration file is /etc/automysqlbackup/myserver.conf" |
|
|
echo " " |
|
|
echo " For a manual play you can use directly" |
|
|
echo " automysqlbackup /etc/automysqlbackup/myserver.conf " |
|
|
echo " else backups are done every night at 04H00 AM with /etc/cron.daily/runmysqlbackup" |
|
|
echo "=========================================================================================" |
|
|
echo " RESTORING" |
|
|
echo " In a root terminal" |
|
|
echo " cd /root/backup/db/ and choose your backup" |
|
|
echo " gunzip file-name.sql.gz" |
|
|
echo " Next you will need to use the mysql client to restore the DB from the sql file." |
|
|
echo " mysql database < /path/file.sql" |
|
|
echo " NOTE: Make sure you use < and not > in the above command because you are piping the file.sql" |
|
|
echo " to mysql and not the other way around" |
|
|
echo "=========================================================================================" |
|
|
echo " Some db configuration for handle this contrib" |
|
|
echo " Mailcontent (stdout/log/files/quiet)" |
|
|
echo " # What would you like to be mailed to you?" |
|
|
echo " # - log : send only log file (default)" |
|
|
echo " # - files : send log file and sql files as attachments (see docs)" |
|
|
echo " #- stdout : will simply output the log to the screen if run manually." |
|
|
echo " #- quiet : Only send logs if an error occurs to the MAILADDR." |
|
|
echo " Sizemail=8000 (bytes)" |
|
|
echo " Mailto=root (or any other user@domaine.com)" |
|
|
echo " Backupdir=path to the folder where mysql files are saved" |
|
|
echo " " |
|
|
echo " ex: config setprop automysqlbackup Mailcontent files" |
|
|
echo "=========================================================================================" |
|
|
|
|
|
|
|
|
|
|
|
#create backupuser and give rights |
|
|
MYSQLPASS=$(/sbin/e-smith/config getprop $SMEDB DbPassword) |
|
|
mysql -e " GRANT 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 |
|
125 |
|
|
126 |
#protect the backup folder |
#protect the backup folder |
127 |
chmod -R 700 /root/backup/db |
chmod -R 700 /root/backup |
128 |
|
|
129 |
%preun |
%preun |
130 |
%postun |
%postun |
132 |
SMEDB=automysqlbackup |
SMEDB=automysqlbackup |
133 |
MYSQLUSER=backupuser |
MYSQLUSER=backupuser |
134 |
echo "=======================================================================" |
echo "=======================================================================" |
135 |
echo " delete mysql user and revoque all permissions" |
echo " " |
136 |
|
echo " delete mysql user and revoke all permissions" |
137 |
# This section deletes backupuser |
# This section deletes backupuser |
138 |
mysql -u root -e "REVOKE ALL PRIVILEGES ON *.* FROM '$MYSQLUSER'@'localhost';" |
mysql -u root -e "REVOKE ALL PRIVILEGES ON *.* FROM '$MYSQLUSER'@'localhost';" |
139 |
mysql -u root -e "DROP USER $MYSQLUSER@localhost;" |
mysql -u root -e "DROP USER $MYSQLUSER@localhost;" |
140 |
echo " " |
echo " " |
141 |
|
echo "Do that for each DB - e.g mysq55, mysql57 etc" |
142 |
|
echo " " |
143 |
# Delete custom template fragment |
# Delete custom template fragment |
144 |
echo " delete db configuration automysqlbackup" |
echo " delete db configuration automysqlbackup" |
145 |
|
echo " " |
146 |
echo "=======================================================================" |
echo "=======================================================================" |
147 |
|
|
148 |
/sbin/e-smith/config delete $SMEDB |
/sbin/e-smith/config delete $SMEDB |