Compare commits

...

52 Commits

Author SHA1 Message Date
Benoît S. aecfb6371f Added a sleep between two rsync (for Online). 2014-04-25 11:16:03 +02:00
Benoît S. bb050ef136 Remove deprecated comments. 2014-04-03 18:09:44 +02:00
Benoît S. 48dfd54b55 Remove debug 2014-04-03 10:33:14 +02:00
Benoît S. 1318ae89c9 Fork of evobackup using rsync --link-dest. 2014-04-02 18:34:58 +02:00
Benoît S. 8a75570ef5 Added steps to INSTALL.md 2014-03-14 18:51:07 +01:00
Benoît S. 2a109bd663 Typo in filename in actions.d. 10_mysq.disabled -> 10_mysql.disabled 2014-03-14 12:13:59 +01:00
Benoît S. dff0d26c27 Change an hard coded path for logging times. 2014-02-14 16:39:52 +01:00
Benoît S. 3df881ca22 New script for Elasticsearch 1.0
in actions.d/14_elasticsearch.disabled
2014-02-13 19:00:48 +01:00
Benoît S. 8188f83d66 Added a check of release to use the good path for libnss. 2014-02-13 11:10:30 +01:00
Benoît S. 879c6d4ffb Revert "Don't use Privilege separation in sshd chroot."
This reverts commit eb6fd1704a.
2014-02-12 19:14:41 +01:00
Benoît S. eb6fd1704a Don't use Privilege separation in sshd chroot. 2014-02-12 18:35:44 +01:00
Benoît S. f972e46012 Send mail report only if incrementals where deleted. 2014-02-12 18:35:44 +01:00
Benoit.S « Benpro » 2ac3d7cf88 Do not pad day of month with zero for calculating node. 2014-02-08 20:59:17 +01:00
Benoît S. 512332de57 Fix issue #10, delete temp empty dir at the end. 2014-02-03 15:51:08 +01:00
Benoit.S « Benpro » 9c75ea0e18 Fix a typo in evobackup-rm.sh & beautifications.
Beautifications of evobackup-inc.sh, evobackup-rm.sh & zzz_evobackup
2014-02-02 20:24:26 +01:00
Benoît S. 609b95e105 All shebangs set to /bin/bash. 2014-01-30 17:00:27 +01:00
Benoît S. 10a676fe6c Ameliorate report when creating or deleting incrementals. 2014-01-30 16:39:34 +01:00
Benoît S. e62bf87b53 Added -h to rsync. 2014-01-30 16:10:49 +01:00
Benoît S. 7411d19b28 Added --stats to rsync and keep 30 last lines for log. 2014-01-30 16:03:58 +01:00
Benoît S. d6baf0c11b Added sleep 0.2 before umounting /dev when stopping service. 2014-01-30 15:49:02 +01:00
Benoît S. ee525abd4c Update INSTALL.md in "What to backup" part. 2014-01-30 15:34:20 +01:00
Benoît S. 905051be35 Don't return *, if bash glob don't find files/dir in evobackup-rm. 2014-01-30 15:25:11 +01:00
Benoît S. 26de127a14 Changed name of logfile for incs. 2014-01-30 15:24:54 +01:00
Benoît S. 2283f283f8 Merge branch 'master' into dev 2014-01-30 15:00:59 +01:00
Benoît S. 5d1dd72c49 Added /dev/pts for jails in Debian init script. 2014-01-30 15:00:08 +01:00
Benoît S. bde85f3f78 Added install/etc/evobackup/conf.d/incs
And a return line for final message in chroot-new.sh
2014-01-30 14:54:22 +01:00
Benoît S. f29553d8cd chroot-new.sh Shebang mush be bash and not sh. 2014-01-30 14:33:39 +01:00
Benoît S. 007d81bd99 Merge branch 'dev' 2014-01-30 14:21:42 +01:00
Benoît S. 056c847031 Didabled all special actions by default. 2014-01-30 11:51:58 +01:00
Benoît S. f01c890b20 Ameliorate action 99_system_info. 2014-01-30 11:50:48 +01:00
Benoît S. 05b28aa8ce Better mkdir in chroot-ssh.
Conflicts:
	chroot-ssh.sh
2014-01-30 11:42:54 +01:00
Benoît S. 21ed15ed34 Exclude database performance_schema for MySQL dumps.
Conflicts:
	zzz_evobackup
2014-01-30 11:38:56 +01:00
Benoît S. d2f9ebc17e Added --events for mysqldump.
Conflicts:
	zzz_evobackup
2014-01-30 11:37:53 +01:00
Benoît S. f02d4bf238 Added a way of backuping ElasticSearch
Conflicts:
	zzz_evobackup
2014-01-30 11:35:13 +01:00
Benoît S. 3d0b3a614e Adding a loop when dumping routes.
Conflicts:
	zzz_evobackup
2014-01-30 11:31:04 +01:00
Benoit.S « Benpro » 3e5f95bbe2 More information for "test" part of the doc. 2013-08-05 22:40:05 +02:00
Benoit.S « Benpro » 60972403fe Added "mount /dev/pts" in upstart job. 2013-08-05 22:16:55 +02:00
Benoit.S « Benpro » 1bf1978d44 Added "test connection" in the install doc. 2013-08-05 22:16:41 +02:00
Benoit.S « Benpro » c688b9d777 Fix issue #2. Better upstart job for Ubuntu. 2013-08-05 21:48:56 +02:00
Benoit.S « Benpro » 526c443d75 Remove old comments. 2013-08-05 21:47:23 +02:00
Benoît S. cddbd002f9 Fix a bug in the way of killing evobackup.
Fix a bug in the way of killing evobackup.

The process is launched by "run-parts /etc/cron.daily". When you kill the
process, run-parts is not informed and the process go in Z state (and rsync
continue to work!). When another run-parts is launched the part wich kill a
process if already launched fail.

This fix this particular bug.
2013-08-05 20:52:19 +02:00
Benoit.S « Benpro » 2cad6c71d3 Adding excludes rules. Chmod 755 for all actions. Changing example server name. 2013-08-04 12:26:49 +02:00
Benoit.S « Benpro » 46dddc7359 Merge branch 'dev' | Fix rsync command line and excludes. 2013-08-04 12:06:59 +02:00
Benoit.S « Benpro » 557fcb282e Added --delete-excluded to rsync command line.
Also exclude /sys by default.
2013-08-04 12:06:20 +02:00
Benoit.S « Benpro » a2fcf5cd3d Rsync command line was bogus. Changing methods using rsync filter rules. 2013-08-04 00:03:56 +02:00
Benoît.S 986349901f Merge pull request #1 from benpro/dev
Fix typo in variable name.
2013-08-03 14:15:58 -07:00
Benoit.S « Benpro » 479e019e1c Fix typo in variable name. 2013-08-03 23:14:54 +02:00
Benoit.S « Benpro » 57142e153d Another fix in README.md 2013-08-03 22:58:20 +02:00
Benoit.S « Benpro » 90b656aef7 Fix formating issue in README.me 2013-08-03 22:57:05 +02:00
Benoit.S « Benpro » eb4c2c6f41 Refactoring of the code.
Evobackup is is now all in english and it is more flexible and easy to
install & configure.
2013-08-03 22:53:04 +02:00
Benoit.S « Benpro » 7968aea863 Merge remote-tracking branch 'upstream/master' 2013-08-01 21:57:37 +02:00
Benoît.S fff1a6027f Initial commit 2013-08-01 12:54:25 -07:00
30 changed files with 774 additions and 780 deletions

4
AUTHORS Normal file
View File

@ -0,0 +1,4 @@
Grégory COLPART <reg@evolix.fr>
Romain DESSORT <rdessort@evolix.fr>
Arnaud TOMEÏ <atomei@evolix.fr>
Benoît SÉRIE <bserie@evolix.fr>

56
INSTALL.md Normal file
View File

@ -0,0 +1,56 @@
Installing EvoBackup
====================
Backup server side
------------------
A rsync daemon launched in server mode.
Client side
-----------
1) Git clone the project (i.e in /root/evobackup).
2) Install configuration files.
```
root@client1:~/evobackup# install.sh client
```
3) Add the zzz_evobackup crontab into the daily cronjobs (recommended):
```
root@client1:~/evobackup# cp crons/zzz_evobackup /etc/cron.daily/
root@client1:~/evobackup# chmod 700 /etc/cron.daily/zzz_evobackup
```
Why "zzz"? Because we want the backup cronjob to be the last one.
4) Configure the cronjob.
In /etc/evobackup:
* What to backup using shell scripts in actions.d. By default all scripts are
disabled. To enable a script, move it by clearing .disabled part.
You can also adapt these scripts or write your own.
This will be launched before the rsync, using run-parts.
* What to backup using rsync filter rules in conf.d/include.cf
* Incrementals to keep in conf.d/incs.cf
* General config in conf.d/cron.cf
5) Optional, test with ```sh -x &```, and see if it seems to works.
```
root@client1:~/evobackup# sh -x /etc/cron.daily/zzz_evobackup &
root@client1:~/evobackup# tail -f /tmp/evobackup.*
```
If it works, you can wait for it to finish or cancel it.
```
root@client1:~/evobackup# ^C
root@client1:~/evobackup# fg
root@client1:~/evobackup# ^C
```

339
LICENSE Normal file
View File

@ -0,0 +1,339 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Backup manager used at @evolix
Copyright (C) 2013 Benoît.S
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
{signature of Ty Coon}, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License.

View File

@ -1,10 +0,0 @@
PLAN DES SAUVEGARDES
====================
PORT JAIL ETAT
-------------------------------------------------------
2222 Serveur 1 (IP) 1
2223 Serveur 2 (IP) 1
2224 Serveur 3 (IP) 0
etc....
.......

215
README
View File

@ -1,215 +0,0 @@
EvoBackup
=========
EvoBackup est un ensemble de scripts permettant de mettre en place
un service de backups gérant les sauvegardes de plusieurs machines.
Le principe est d'installer des prisons/chroot contenant un service
SSH écoutant sur un port différent dans chaque prison. Chaque serveur
peut ainsi envoyer ses données quotidiennement en "root" via rsync
dans sa propre prison. Les prisons sont ensuite copiées en dehors des
prisons (donc inacccessible par les serveurs) de façon incrémentale
grâce à des "hard links". On peut ainsi conserver des dizaines de
sauvegardes de chaque serveur de façon sécurisé et avec peu de place.
**************************
Serveur 1 ------SSH/rsync -------> * tcp/2222 Serveur *
* de *
Serveur 2 ------SSH/rsync -------> * tcp/2223 Sauvegardes *
**************************
Cette technique de sauvegarde s'appuient sur des technologies
standards. Elle est utilisée depuis plusieurs années par Evolix
pour sauvegarder chaque jour des centaines de serveurs représentant
plusieurs To de données incrémentales.
Serveur de sauvegardes
----------------------
Le serveur de sauvegardes doit être sous Debian Squeeze
(testé sous Etch/Lenny/Squeeze, les instructions sont pour Squeeze).
Avec les logiciels suivants :
- OpenSSH
- Rsync (le daemon rsync n'est pas nécessaire)
- Le paquet makedev (plus nécessaire depuis Squeeze)
- Commande "mail" (ou un équivalent) capable d'envoyer
des messages à l'extérieur.
Un volume d'une taille importante doit être monté sur /backup
Pour des raisons de sécurité on pourra chiffre ce volume.
On créera ensuite les répertoires suivants :
- /backup/jails : pour les prisons
- /backup/incs : pour les copies incrémentales des prisons
- /etc/evobackup : config des fréquences des copies incrémentales
Pour la mise en place des backups incrémentaux sur le serveur :
- Mettre en place les scripts evobackup-inc.sh et evobackup-rm.sh dans /usr/share/scripts
- Mettre les droits d'exécution : chmod u+x /usr/share/scripts/evobackup-{inc,rm}.sh
- Activer le crontab suivant (ajuster éventuellement les heures) :
29 10 * * * pkill evobackup-rm.sh && echo "Kill evobackup-rm.sh done" | mail -s "[warn] EvoBackup - purge incs interrupted" root
30 10 * * * /usr/share/scripts/evobackup-inc.sh && /usr/share/scripts/evobackup-rm.sh
Note : si l'on ne veut *jamais* supprimer les backups incrémentaux, on pourra se contenter
de ne jamais lancer le script evobackup-rm.sh
Si le noyau du serveur est patché avec GRSEC, on évitera pas mal
de warnings en positionnant les paramètres Sysctl suivants :
# sysctl kernel.grsecurity.chroot_deny_chmod=0
# sysctl kernel.grsecurity.chroot_deny_mknod=0
Note : plus nécessaire avec un noyau récent a priori
Serveurs à sauvegarder
----------------------
On peut sauvegarder différents systèmes : Linux, BSD, Windows, MacOSX.
L'un des seuls prérequis est d'avoir rsync.
Installation d'une sauvegarde
-----------------------------
Côté serveur de sauvegardes
~~~~~~~~~~~~~~~~~~~~~~~~~~~
1) On récupère les sources via http://git.evolix.org/git/evolinux/evobackup.git
- Exporter la variable $JAIL avec le nom d'hôte saisit dans la grille :
# export JAIL=<nom d'hote>
- Se placer dans le bon répertoire (attention, ne pas déplacer le script car
il a besoin du répertoire etc/ !) puis exécuter :
# bash chroot-ssh.sh /backup/jails/$JAIL
Note : Ignorer une éventuelle erreur avec ld-linux-x86-64.so.2 (32bits) ou ld-linux.so.2 (64bits)
- Editer le fichier /backup/jails/$JAIL/etc/ssh/sshd_config
et remplacer le port SSH utilisé par le prochain disponible
(ou garder celui assigné si c'est la première prison).
Ajouter également la restriction d'IP si possible via "AllowUsers" :
AllowUsers root@IP root@::ffff:IP
- Ajouter la clé publique du client à sauvegarder dans
/backup/jails/$JAIL/root/.ssh/authorized_keys
- Puis corrigez les droits SSH :
# chmod -R 600 /backup/jails/$JAIL/root/.ssh/
# chown -R root:root /backup/jails/$JAIL/root/.ssh/
2) Gestion du lancement des prisons en modifiant le fichier de démarrage
/etc/init.d/evobackup (on remplacera $JAIL par sa vraie valeur).
- Ajouter à start) :
mount -t proc proc-chroot /backup/jails/$JAIL/proc/
mount -t devtmpfs udev /backup/jails/$JAIL/dev/
chroot /backup/jails/$JAIL /usr/sbin/sshd > /dev/null
- Ajouter à stop) :
umount /backup/jails/$JAIL/proc/
umount /backup/jails/$JAIL/dev/
kill -9 `chroot /backup/jails/$JAIL cat /var/run/sshd.pid`
- Ajouter à reload|force-reload) :
kill -HUP `chroot /backup/jails/$JAIL cat /var/run/sshd.pid`
- Ajouter à restart) :
kill -9 `chroot /backup/jails/$JAIL cat /var/run/sshd.pid`
chroot /backup/jails/$JAIL /usr/sbin/sshd > /dev/null
3) On lance la prison :
# mount -t proc proc-chroot /backup/jails/$JAIL/proc/
# mount -t devtmpfs udev /backup/jails/$JAIL/dev/
# chroot /backup/jails/$JAIL /usr/sbin/sshd > /dev/null
Pour vérifier que tout est OK :
# /etc/init.d/evobackup reload
4) Gestion des sauvegardes incrémentales
Pour activer les gestions des copies incrémentales,
créer le fichier /etc/evobackup/$JAIL contenant par
exemple :
+%Y-%m-%d.-0day
+%Y-%m-%d.-1day
+%Y-%m-%d.-2day
+%Y-%m-%d.-3day
+%Y-%m-01.-0month
+%Y-%m-01.-1month
Quelques explications sur cette syntaxe particulière.
Par exemple, la ligne ci-dessous signifie "garder la sauvegarde du
jour actuel" (à toujours mettre sur la première ligne a priori) :
+%Y-%m-%d.-0day
La ligne ci-dessous signifie "garder la sauvegarde d'hier" :
+%Y-%m-%d.-1day
La ligne ci-dessous signifie "garder la sauvegarde du 1er jour du
mois courant" :
+%Y-%m-01.-0month
Toujours le même principe, on peut garder celle du 1er jours du
mois dernier :
+%Y-%m-01.-1month
Et bien sûr, on peut garder aussi le 15e jour (pour avoir une sauvegarde
toutes les 15 jours, le 1er janvier de chaque année, etc.)
Attention, la création de ce fichier est *obligatoire* pour activer
les copies incrémentales. Si l'on veut garder des copies advitam aeternam
sans jamais les supprimer, on se contentera de ne pas lancer le script
evobackup-rm.sh.
Côté serveur à sauvegarder
~~~~~~~~~~~~~~~~~~~~~~~~~~
1) Générez une clé SSH pour l'utilisateur "root" :
# ssh-keygen
(Ne pas la protéger par une passphrase, sauf si un humain
va l'entrer manuellement à chaque sauvegarde effectuée)
(La clé générée doit être de type RSA et non DSA !!)
2) Envoyez "/root/.ssh/id_rsa.pub" au responsable du serveur de
sauvegarde, ainsi que l'adresse IP de la machine.
3) Ajoutez à la crontab le fichier "zzz_evobackup"
Pour une sauvegarde quotidienne (conseillé), utilisez le répertoire
"/etc/cron.daily/" (sous Linux) ou "/etc/periodic/daily" (sous FreeBSD).
Il faut éventuellement ajuster le script en supprimant les lignes "--exclude"
si l'on ne souhaite pas exclure les fichiers/répertoires de cette ligne et
ajouter/supprimer les lignes en dessous pour sauvegarder les bons répertoires.
($rep désigne les données systèmes). Vous pouvez donc choisir librement ce
que vous désirez sauvegarder.
4) Une fois que tout en place au niveau du serveur de sauvegardes,
on doit initier la première connexion :
# ssh -p <port> <serveur de sauvegardes>
Mise-à-jour du serveur de sauvegardes
-------------------------------------
En cas d'une mise-à-jour d'un paquet lié à SSH ou rsync côté
serveur de sauvegardes, on mettra à jour ainsi :
# sh chroot-ssh.sh updateall
# /etc/init.d/evobackup restart

28
README.md Normal file
View File

@ -0,0 +1,28 @@
EvoBackup-linkdest
=========
(Fork of EvoBackup using rsync --link-dest as incrementals).
EvoBackup is a bunch of shell scripts to backup a machine to a rsync server.
Licence is GPLv2.
This method uses standard tools (ssh, rsync). EvoBackup is used for
many years by Evolix for back up each day hundreds of servers which uses many
terabytes of data.
Backup server
-------------
The backup server need to use rsync. Evobackup-linkdest was tested only on
Online backup offer using rsync and RPN.
Needed packages:
* rsync
* bsd-mailx (or other package providing /usr/bin/mailx)
Main directories:
* /etc/evobackup: Config dir
To install and configure EvoBackup read INSTALL.md

View File

@ -1,132 +0,0 @@
#!/bin/bash
# Gregory Colpart <reg@evolix.fr>
# chroot script for OpenSSH
# $Id: chroot-ssh.sh,v 1.12 2010-07-02 17:40:29 gcolpart Exp $
# tested on Debian Etch and recently on Lenny
# Exec this script for jail creation:
# ./chroot-ssh.sh /backup/jails/myserver
# Note: etc/{sshd_config,group,passwd} files should be present
# For Etch
# Start: chroot /backup/jails/myserver /usr/sbin/sshd > /dev/null
# Reload: kill -HUP `chroot /backup/jails/myserver cat /var/run/sshd.pid`
# Stop: kill -9 `chroot /backup/jails/myserver cat /var/run/sshd.pid`
# Restart: Stop + Start
# For Lenny
# Start :
# chroot /backup/jails/myserver mount -t proc proc-chroot /proc/
# chroot /backup/jails/myserver mount -t devpts devpts-chroot /dev/pts/
# chroot /backup/jails/myserver /usr/sbin/sshd > /dev/null
# Reload: kill -HUP `chroot /backup/jails/myserver cat /var/run/sshd.pid`
# Stop: kill -9 `chroot /backup/jails/myserver cat /var/run/sshd.pid`
# Restart:
# kill -9 `chroot /backup/jails/myserver cat /var/run/sshd.pid`
# chroot /backup/jails/myserver /usr/sbin/sshd > /dev/null
# After *each* ssh upgrade or libs upgrade:
# sh chroot-ssh.sh updateall
# And restart all sshd daemons
bincopy() {
chrootdir=$1
# TODO : better detection of amd64 arch
cp -f /lib/ld-linux.so.2 $chrootdir/lib/ || cp -f /lib64/ld-linux-x86-64.so.2 $chrootdir/lib64/
cp /lib/libnss* $chrootdir/lib/
for dbin in /bin/bash /bin/cat /bin/chown /bin/mknod /bin/rm /bin/sed /bin/sh /bin/uname /bin/mount /usr/bin/rsync /usr/sbin/sshd /usr/lib/openssh/sftp-server; do
cp -f $dbin $chrootdir/$dbin;
# (comme dans http://www.gcolpart.com/hacks/chroot-bind.sh)
for lib in `ldd $dbin | cut -d">" -f2 | cut -d"(" -f1`; do
cp -p $lib $chrootdir/$lib
done
done
}
# synopsis
if [ $# -ne 1 ]; then
echo "Vous devez indiquer un repertoire."
echo "Exemple : chroot-ssh.sh /backup/jails/myserver"
exit 0
fi
# are u root?
if [ `whoami` != "root" ]; then
echo "Vous devez executer le script en étant root."
exit 0
fi
if [ -e $1 ]; then
echo "Le repertoire $1 existe deja..."
fi
if [ "$1" = "updateall" ]; then
for i in `ls -1 /backup/jails/*/lib/libnss_compat.so.2`; do
chrootdir=`echo $i | cut -d"/" -f1,2,3,4`
echo -n "MaJ $chrootdir ..."
bincopy $chrootdir
echo "...OK"
done
else
# where is jail
chrootdir=$1
mkdir -p $chrootdir
chown root:root $chrootdir
umask 022
# create jail
echo -n "1 - Creation de la prison..."
mkdir -p $chrootdir/{bin,dev,etc/ssh,lib,lib64}
mkdir -p $chrootdir/lib/tls/i686/cmov/
mkdir -p $chrootdir/proc
mkdir -p $chrootdir/root/.ssh
mkdir -p $chrootdir/usr/lib/i686/cmov/
mkdir -p $chrootdir/lib/i686/cmov/
mkdir -p $chrootdir/usr/{bin,lib,sbin}
mkdir -p $chrootdir/usr/lib/openssh
mkdir -p $chrootdir/var/log/
mkdir -p $chrootdir/var/run/sshd
touch $chrootdir/var/log/{authlog,lastlog,messages,syslog}
touch $chrootdir/etc/fstab
echo "...OK"
echo -n "2 - Copie des donnees..."
cp /proc/devices $chrootdir/proc
cp /etc/ssh/{ssh_host_rsa_key,ssh_host_dsa_key} $chrootdir/etc/ssh/
cp etc/sshd_config $chrootdir/etc/ssh/
cp etc/passwd $chrootdir/etc/
cp etc/shadow $chrootdir/etc/
cp etc/group $chrootdir/etc/
echo ".......OK"
echo -n "3 - Copie des binaires..."
bincopy $chrootdir
echo "......OK"
echo -n "4 - Termine."
# end
echo ""
fi

44
crons/evobackup-rm.sh Normal file
View File

@ -0,0 +1,44 @@
#!/bin/bash
# Handle removing of incrementals.
. /etc/evobackup/conf.d/cron.cf
tmpdir=$(mktemp --tmpdir=/tmp -d evobackup.tmpdir.XXX)
emptydir=$(mktemp --tmpdir=/tmp -d evobackup.empty.XXX)
tmplog=$(mktemp --tmpdir=/tmp evobackup.tmplog.XXX)
dst="rsync://${RSYNC_USERNAME}@${BACKUPSERVER}/${RSYNC_PATH}"
# List actual incrementals backup.
listincs=$(rsync --list-only ${dst} |
sed -E 's#^([^\s]+\s+){4}##' | sed -e '/\./d' -e '/current/d' | tr -s '\n' ' '
)
for inc in $listincs; do
echo $inc >> ${tmpdir}/incs.files
done
# List non-obsolete incrementals backup.
for incConf in $(cat ${CONFDIR}/incs.cf); do
mydate=$(echo $incConf | cut -d. -f1)
before=$(echo $incConf | cut -d. -f2)
date -d "$(date $mydate) $before" "+%Y-%m-%d"
done > ${tmpdir}/incs.keep
# Delete obsolete incrementals backup
for inc in $(grep -v -f ${tmpdir}/incs.keep ${tmpdir}/incs.files); do
start=$(date --rfc-3339=seconds)
echo "Deletion of $inc started at ${start}." >> $tmplog
rsync -a --delete ${emptydir}/ ${dst}/${inc}
sleep 5
rsync -a --delete --include="${inc}" --exclude="*" ${emptydir}/ $dst
stop=$(date --rfc-3339=seconds)
echo "Deletion of $inc ended at ${stop}." >> $tmplog
done
# Send mail report only if incrementals where deleted.
if [ -s $tmplog ]; then
# Save tmplog to global log & send mail.
cat $tmplog >> $LOG
< $tmplog mailx -s "[info] EvoBackup - deletion of obsolete incrementals" $MAIL_TO
fi
# Cleaning
rm -rf $tmpdir $emptydir $tmplog

60
crons/zzz_evobackup Normal file
View File

@ -0,0 +1,60 @@
#!/bin/bash
# EvoBackup cronjob.
. /etc/evobackup/conf.d/cron.cf
# Verify if an EvoBackup is already launched, if true, kill it.
if [ -e $PIDFILE ]; then
# Killing the childs of evobackup.
for pid in $(ps h --ppid $(cat $PIDFILE) -o pid | tr -s '\n' ' '); do
kill -9 $pid;
done
# Then kill the main PID.
kill -9 $(cat $PIDFILE)
echo "$0 is running (PID $(cat $PIDFILE)). Process killed." >&2
fi
echo "$$" > $PIDFILE
trap "rm -f $PIDFILE" EXIT INT
# Executes tasks to do before rsync.
run-parts /etc/evobackup/actions.d/
hostname=$(hostname -f)
start=$(date --rfc-3339=seconds)
date=$(date +%Y-%m-%d)
tmplog=$(mktemp --tmpdir=/tmp evobackup.XXX)
args="-avzh --stats --force --ignore-errors --partial "\
"--include-from=/etc/evobackup/conf.d/include.cf "\
"--delete --delete-excluded"
dst="rsync://${RSYNC_USERNAME}@${BACKUPSERVER}/${RSYNC_PATH}"
# Is there a current version? If no create it.
rsync --list-only ${dst}/current >/dev/null 2>&1
status=$?
if [ "$status" != 0 ]; then
# First backup.
rsync $args / ${dst}/current > $tmplog
else
# Backups with incrementials.
rsync $args --link-dest=/current/ / ${dst}/${date} > $tmplog
fi
status=$?
# Keep the last 30 lines & clean temporary log.
tail -30 $tmplog >> $LOG && rm $tmplog
stop=$(date --rfc-3339=seconds)
echo "EvoBackup started at $start." >> $LOG
echo "EvoBackup finished at $stop." >> $LOG
# Send a report
# Did rsync sucessfully finished?
if [ "$status" != 0 ]; then
tail -30 $LOG \
| mailx -s "[warn] EvoBackup for $hostname did not finish correctly." \
$MAIL_TO
else
tail -30 $LOG \
| mailx -s "[info] EvoBackup report for $hostname" $MAIL_TO
fi

View File

@ -1,7 +0,0 @@
root:x:0:
daemon:x:1:
shadow:x:42:
staff:x:50:
users:x:100:
nogroup:x:65534:
ssh:x:102:

View File

@ -1,4 +0,0 @@
root:x:0:0:root:/root:/bin/bash
daemon:x:1:1:daemon:/usr/sbin:/bin/sh
nobody:x:65534:65534:nobody:/nonexistent:/bin/sh
sshd:x:100:65534::/var/run/sshd:/usr/sbin/nologin

View File

@ -1,4 +0,0 @@
root:x:13536:0:99999:7:::
daemon:*:13536:0:99999:7:::
nobody:*:13536:0:99999:7:::
sshd:!:13536:0:99999:7:::

View File

@ -1,35 +0,0 @@
Port 2222
Protocol 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
UsePrivilegeSeparation yes
KeyRegenerationInterval 3600
ServerKeyBits 768
SyslogFacility AUTH
LogLevel INFO
LoginGraceTime 120
PermitRootLogin yes
StrictModes yes
RSAAuthentication yes
PubkeyAuthentication yes
AuthorizedKeysFile %h/.ssh/authorized_keys
IgnoreRhosts yes
RhostsRSAAuthentication no
HostbasedAuthentication no
PermitEmptyPasswords no
ChallengeResponseAuthentication no
PasswordAuthentication no
X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
TCPKeepAlive yes
UseLogin no
Subsystem sftp /usr/lib/openssh/sftp-server
AllowUsers root@IP root@::ffff:IP

View File

@ -1,29 +0,0 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: evobackup
# Required-Start: $syslog
# Required-Stop: $syslog
# Default-Start: 2
# Default-Stop: 1
# Short-Description: evobackup jails
### END INIT INFO
set -e
case "$1" in
start)
;;
stop)
;;
reload|force-reload)
;;
restart)
;;
esac
exit 0

View File

@ -1,27 +0,0 @@
#!/bin/sh
# Script backups incrementaux
# Evolix (c) 2007
CONFDIR=/etc/evobackup/
DATE=$(date +"%d-%m-%Y")
LOGFILE=/var/log/evobackup-sync.log
TMPDIR=/tmp/evobackup/
JAILDIR=/backup/jails/
INCDIR=/backup/incs/
MYMAIL=jdoe@example.com
mkdir -p $TMPDIR
for i in $( ls $CONFDIR ); do
# hard copy everyday
echo -n "hard copy $i begins at : " >> $LOGFILE
/bin/date +"%d-%m-%Y ; %H:%M" >> $LOGFILE
mkdir -p "$INCDIR"$i
cp -alx $JAILDIR$i $INCDIR$i/$DATE
echo -n "hard copy $i ends at : " >> $LOGFILE
/bin/date +"%d-%m-%Y ; %H:%M" >> $LOGFILE
done | tee -a $LOGFILE | mail -s "[info] EvoBackup - create incs" $MYMAIL

View File

@ -1,41 +0,0 @@
#!/bin/sh
# Script backups incrementaux
# Evolix (c) 2007
CONFDIR=/etc/evobackup/
DATE=$(date +"%d-%m-%Y")
LOGFILE=/var/log/evobackup-sync.log
TMPDIR=/tmp/evobackup/
JAILDIR=/backup/jails/
INCDIR=/backup/incs/
MYMAIL=jdoe@example.com
mkdir -p $TMPDIR
for i in $( ls $CONFDIR ); do
# list actual inc backups
for j in $( ls $INCDIR$i ); do
echo $j
done > "$TMPDIR"$i.files
# list non-obsolete inc backups
for j in $( cat $CONFDIR$i ); do
MYDATE=$( echo $j | cut -d. -f1 )
BEFORE=$( echo $j | cut -d. -f2 )
date -d "$(date $MYDATE) $BEFORE" "+%d-%m-%Y"
done > "$TMPDIR"$i.keep
# delete obsolete inc backups
for j in $( grep -v -f "$TMPDIR"$i.keep "$TMPDIR"$i.files ); do
echo -n "Delete $i/$j begins at : " >> $LOGFILE
/bin/date +"%d-%m-%Y ; %H:%M" >> $LOGFILE
cd $INCDIR$i
rm -rf $j
echo -n "Delete $i/$j ends at : " >> $LOGFILE
/bin/date +"%d-%m-%Y ; %H:%M" >> $LOGFILE
done
done | tee -a $LOGFILE | mail -s "[info] EvoBackup - purge incs" $MYMAIL

34
install.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# Install EvoBackup configuration and init files.
# Debian or Ubuntu?
flavor=$(lsb_release -i -s)
debian=false
ubuntu=false
if [ "$flavor" = "Debian" ]; then
echo "Debian detected."
debian=true
elif [ "$flavor" = "Ubuntu" ]; then
echo "Ubuntu detected."
ubuntu=true
else
echo "Not a Debian based distribution? If yes, fix this script. Exiting..."
exit 1
fi
# Are we root?
id=$(id -u)
if [ $id != 0 ]; then
echo "Error, you need to be root to install EvoBackup!"
exit 1
fi
cp -r install/etc/evobackup /etc/
# Don't install init script for client-side.
if [ "$1" != "client" ]; then
$debian && cp install/etc/init.d/evobackup /etc/init.d/
$ubuntu && cp install/etc/init/evobackup.conf /etc/init/
fi
echo "Done."
exit 0

View File

@ -0,0 +1,5 @@
#!/bin/bash
# Prerequisites actions to do.
test ! -d /home/backup && mkdir /home/backup
exit 0

View File

@ -0,0 +1,44 @@
#!/bin/bash
# Many ways of backuping MySQL/MariaDB databases.
# Dump with all databases in one file.
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf \
# --opt --all-databases --force --events | gzip --best > /home/backup/mysql.bak.gz
# Dump des BDD en .sql.gz
# mkdir -p /home/mysqldump/
# for i in $(mysql -e 'show databases' -s --skip-column-names | egrep -v "^(Database|information_schema|performance_schema)"); do
# mysqldump --force --events $i | gzip --best > /home/mysqldump/${i}.sql.gz
# done
# for i in $(echo SHOW DATABASES | mysql | egrep -v "^(Database|information_schema|performance_schema)" ); \
# do mkdir -p /home/mysqldump/$i ; chown -R mysql /home/mysqldump ; \
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q --opt --events --skip-comments -T \
# /home/mysqldump/$i $i; done
# Dump par base
# mkdir -p -m 700 /home/mysqldump/BASE
# chown -R mysql /home/mysqldump/
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q \
# --opt --events --skip-comments -T /home/mysqldump/BASE BASE
# mkdir -p /home/mysqlhotcopy/
# mysqlhotcopy BASE /home/mysqlhotcopy/
# Dump instanceS MySQL
#
## Recherche du mot de passe mysqladmin
#mysqladminpasswd=`cat /root/.my.cnf |grep -m1 'password = .*' |cut -d" " -f3`
#
## Determination des instances MySQL disponibles sur le serveur (hors 3306)
#grep -E "^port\s*=\s*\d*" /etc/mysql/my.cnf |while read instance; do
# instance=$(echo $instance |tr -d '\t')
# instance=${instance// /}
# instance=${instance//port=/}
# if [ "$instance" != "3306" ]
# then
# mysqldump -P $instance --opt --all-databases -u mysqladmin -p$mysqladminpasswd > /home/backup/mysql.$instance.bak
# fi
#done
exit 0

View File

@ -0,0 +1,15 @@
#!/bin/bash
# PostgreSQL Dump
# su - postgres -c "pg_dumpall > ~/pg.dump.bak"
# mv ~postgres/pg.dump.bak /home/backup/
# Exemple de backups...
# On sauvegarde les tables d'une base sauf des exceptions
# pg_dump -p 5432 -h 127.0.0.1 -U USER --clean -F t --inserts -f
#/home/backup/pg-backup.tar -t 'TABLE1' -t 'TABLE2' BASE
# On sauvegarde uniquement certaines tables d'une base
# pg_dump -p 5432 -h 127.0.0.1 -U USER --clean -F t --inserts -f
#/home/backup/pg-backup.tar -T 'TABLE1' -T 'TABLE2' BASE
exit 0

View File

@ -0,0 +1,6 @@
#!/bin/bash
# Dump Redis
# cp /var/lib/redis/dump.rdb /home/backup/
exit 0

View File

@ -0,0 +1,7 @@
#!/bin/bash
# Dump MongoDB
# mongodump -u mongobackup -pPASS -o /home/backup/mongodump/ >/dev/null 2>&1
# |grep -v "^connected to:"
exit 0

View File

@ -0,0 +1,29 @@
#!/bin/bash
# Dump/Snapshots for Elasticsearch 1.0
## Yout need to register a repository, this action need to be only done one time,
## but you must register a repository on all nodes!
## $ curl -XPUT 'http://localhost:9200/_snapshot/backup' -d '{
## "type": "fs",
## "settings": {
## "location": "/home/backup-elasticsearch",
## "compress": true
## }
## }'
## Delete old snapshots. Handled in EvoBackup.
# rm -rf /home/backup/elasticsearch/*
## Take a snapshot on master node.
# date=$(date +%Y%m%d%H%M)
# curl -XPUT "localhost:9200/_snapshot/backup/snapshot_${date}?wait_for_completion=true"
## To restore: List snapshots, close all indexes & restore one snapshot.
## curl -XGET "localhost:9200/_snapshot/backup/_all?pretty=true"
## curl -XPOST "localhost:9200/_all/_close"
## rsync master node:/home/backup/elasticsearch to slaves nodes
## example : rsync -av --delete /home/backup/elasticsearch node:/home/backup/elasticsearch
## restore snapshots
## curl -XPOST "localhost:9200/_snapshot/backup/snapshot_DATE/_restore?wait_for_completion=true"
exit 0

View File

@ -0,0 +1,6 @@
#!/bin/bash
# Dump LDAP
# slapcat -l /home/backup/ldap.bak
exit 0

View File

@ -0,0 +1,26 @@
#!/bin/bash
# Get system informations.
# Dependency: dd, sfdisk, mtr, traceroute, ps, netstat, dpkg
# Extract MBR / table partitions.
dd if=/dev/sda of=/home/backup/MBR bs=512 count=1 2>&1 | \
egrep -v "(records in|records out|512 bytes)"
sfdisk -d /dev/sda > /home/backup/partitions 2>&1 | \
egrep -v "(Warning: extended partition does not start at a cylinder boundary|DOS and Linux will interpret the contents differently)"
# Get routes
for addr in 8.8.8.8 backup.evolix.net www.evolix.fr www.evolix.net; do
mtr -r $addr > /home/backup/mtr-${addr}
traceroute -n $addr > /home/backup/traceroute-${addr}
done
# Process list.
ps auwwwx > /home/backup/process.txt
# Network connections list.
netstat -taupen > /home/backup/netstat.txt
# Packages list.
dpkg -l > /home/backup/packages.txt
exit 0

View File

@ -0,0 +1,28 @@
# Pid file
PIDFILE="/var/run/evobackup.pid"
# Port of the rsync backup server. Default is 837.
PORT=837
# Hostname OR adress IP of the backup server.
BACKUPSERVER="mybackupserver.domain.tld"
# Username, if any.
RSYNC_USERNAME=""
# Password, if any.
export RSYNC_PASSWORD=""
# Path used by rsync server.
RSYNC_PATH="backup"
# A mail to send the report or alert.
MAIL_TO="jdoe@example.com"
# Log file
LOG="/var/log/evobackup.log"
# Used when you have more than one backup server.
NODE=$(( $(date +%-d) % 2 ))
CONFDIR=/etc/evobackup/conf.d

View File

@ -0,0 +1,37 @@
# Use this file to exlude files (-) or explicit include (+).
# Exemple, backup /home/backup/mysql.bak.gz but not what is left in /home/backup
# + /home/backup/mysql.bak.gz
# - /home/backup/**
# General excludes.
- lost+found
- .nfs.*
- /backup
- /dev
- /lib
- /proc
- /selinux
- /run
- /sys
- /tmp
- /usr/doc
- /usr/lib
- /usr/src
- /usr/share/doc
- /usr/obj
- /var/log
- /var/lib/mysql
- /var/lib/postgres
- /var/lib/postgresql
- /var/lib/sympa
- /var/lib/metche
- /var/run
- /var/lock
- /var/state
- /var/apt
- /var/cache
- /var/spool/postfix
- /var/lib/amavis/amavisd.sock
- /var/lib/munin/munin-update.stats.tmp
- /var/lib/php5
- /var/spool/squid

View File

@ -0,0 +1,6 @@
+%Y-%m-%d.-0day
+%Y-%m-%d.-1day
+%Y-%m-%d.-2day
+%Y-%m-%d.-3day
+%Y-%m-01.-0month
+%Y-%m-01.-1month

View File

@ -1,101 +0,0 @@
#!/bin/sh
BACKUP_ROOT='/backup'
function usage {
cat <<EOT >&2
Add an evobackup jail.
Usage : $0 -n name -i ip -p port -k pub-key-path
All these options are required
-n : name of the jail
-i : IP address of client machine
-p : SSH port where jail listen on
-k : path to the SSH public key of the client machine
EOT
}
while getopts ':n:i:p:k:' o
do
case $o in
n)
jail=$OPTARG
;;
i)
ip=$OPTARG
;;
p)
port=$OPTARG
;;
k)
pub_key_path=$OPTARG
;;
?)
usage
exit 1
;;
esac
done
if [ -z $jail ] || [ -z $ip ] || [ -z $port ] || [ -z $pub_key_path ]; then
usage
exit 1
fi
if [ ! -f "$pub_key_path" ]; then
echo "public key file $pub_key_path not found."
exit 1
fi
if [ ! -f 'chroot-ssh.sh' ]; then
echo 'script chroot-ssh.sh not found, make sure you are in the correct directory!'
exit 1
fi
bash chroot-ssh.sh $BACKUP_ROOT/jails/$jail
sed -i "s/^Port 2222/Port $port/" $BACKUP_ROOT/jails/$jail/etc/ssh/sshd_config
sed -i "s/IP/$ip/g" $BACKUP_ROOT/jails/$jail/etc/ssh/sshd_config
cat $pub_key_path >> $BACKUP_ROOT/jails/$jail/root/.ssh/authorized_keys
chmod -R 600 $BACKUP_ROOT/jails/$jail/root/.ssh/
chown -R root:root $BACKUP_ROOT/jails/$jail/root/.ssh/
if [ ! -f '/etc/init.d/evobackup' ]; then
cp evobackup /etc/init.d/
update-rc.d evobackup start 99 2 .
fi
sed -i "\?^\s\+start)?a mount -t proc proc-chroot $BACKUP_ROOT/jails/$jail/proc/\n\
mount -t devpts devpts-chroot $BACKUP_ROOT/jails/$jail/dev/pts/\n\
chroot $BACKUP_ROOT/jails/$jail /usr/sbin/sshd > /dev/null\n" \
/etc/init.d/evobackup
sed -i "\?^\s\+stop)?a umount $BACKUP_ROOT/jails/$jail/proc/\n\
umount $BACKUP_ROOT/jails/$jail/dev/pts/\n\
kill -9 \`chroot $BACKUP_ROOT/jails/$jail cat /var/run/sshd.pid\`\n" \
/etc/init.d/evobackup
sed -i "\?force-reload)?a kill -HUP \`chroot $BACKUP_ROOT/jails/$jail cat /var/run/sshd.pid\`\n" \
/etc/init.d/evobackup
sed -i "\?\\s\+restart)?a kill -9 \`chroot $BACKUP_ROOT/jails/$jail cat /var/run/sshd.pid\`\n\
chroot $BACKUP_ROOT/jails/$jail /usr/sbin/sshd > /dev/null\n" \
/etc/init.d/evobackup
mount -t proc proc-chroot /backup/jails/$jail/proc/
mount -t devpts devpts-chroot /backup/jails/$jail/dev/pts/
chroot /backup/jails/$jail /usr/sbin/sshd
[ -d /etc/evobackup ] || mkdir /etc/evobackup/
cat <<EOT >/etc/evobackup/$jail
+%Y-%m-%d.-0day
+%Y-%m-%d.-1day
+%Y-%m-%d.-2day
+%Y-%m-%d.-3day
+%Y-%m-01.-0month
+%Y-%m-01.-1month
EOT

View File

@ -1,175 +0,0 @@
#!/bin/sh
#
# Script evobackup client
# $Id: evobackup_cron_daily_client,v 1.21 2010-08-22 10:15:42 gcolpart Exp $
#
# Verification qu'un autre evobackup n'est pas deja lance
PIDFILE=/var/run/evobackup.pid
if [ -e $PIDFILE ]; then
pkill -9 -F $PIDFILE
echo "$0 tourne encore (PID `cat $PIDFILE`). Processus killé" >&2
fi
echo "$$" > $PIDFILE
trap "rm -f $PIDFILE" EXIT
# port SSH
SSH_PORT=2228
# systeme de la machine ("linux" ou "bsd")
SYSTEME=linux
# mail de remontee Evolix
MAIL=jdoe@example.com
NODE=$(expr `date +%d` % 2)
# operations specifiques
mkdir -p -m 700 /home/backup
# Dump LDAP
# slapcat -l /home/backup/ldap.bak
# Dump MySQL
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf \
# --opt --all-databases --force | gzip --best > /home/backup/mysql.bak.gz
# Dump des BDD en .sql.gz
# mkdir -p /home/mysqldump/
# for i in $(mysql -e 'show databases' -s --skip-column-names | egrep -v "^(Database|information_schema)"); do
# mysqldump --force $i | gzip --best > /home/mysqldump/${i}.sql.gz
# done
# for i in $(echo SHOW DATABASES | mysql | egrep -v "^(Database|information_schema)" ); \
# do mkdir -p /home/mysqldump/$i ; chown -R mysql /home/mysqldump ; \
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q --opt -T \
# /home/mysqldump/$i $i; done
# Dump par base
# mkdir -p -m 700 /home/mysqldump/BASE
# chown -R mysql /home/mysqldump/
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q \
# --opt -T /home/mysqldump/BASE BASE
# mkdir -p /home/mysqlhotcopy/
# mysqlhotcopy BASE /home/mysqlhotcopy/
# Dump instanceS MySQL
#
## Recherche du mot de passe mysqladmin
#mysqladminpasswd=`cat /root/.my.cnf |grep -m1 'password = .*' |cut -d" " -f3`
#
## Determination des instances MySQL disponibles sur le serveur (hors 3306)
#grep -E "^port\s*=\s*\d*" /etc/mysql/my.cnf |while read instance; do
# instance=$(echo $instance |tr -d '\t')
# instance=${instance// /}
# instance=${instance//port=/}
# if [ "$instance" != "3306" ]
# then
# mysqldump -P $instance --opt --all-databases -u mysqladmin -p$mysqladminpasswd > /home/backup/mysql.$instance.bak
# fi
#done
# Dump PostgreSQL
# su - postgres -c "pg_dumpall > ~/pg.dump.bak"
# mv ~postgres/pg.dump.bak /home/backup/
# Exemple de backups...
# On sauvegarde les tables d'une base sauf des exceptions
# pg_dump -p 5432 -h 127.0.0.1 -U USER --clean -F t --inserts -f /home/backup/pg-backup.tar -t 'TABLE1' -t 'TABLE2' BASE
# On sauvegarde uniquement certaines tables d'une base
# pg_dump -p 5432 -h 127.0.0.1 -U USER --clean -F t --inserts -f /home/backup/pg-backup.tar -T 'TABLE1' -T 'TABLE2' BASE
# Dump MongoDB
# Creation d'un utilisateur en lecture seule :
# > use admin
# > db.addUser("mongobackup", "PASS", true);
#mongodump -u mongobackup -pPASS -o /home/backup/mongodump/ >/dev/null 2>&1 |grep -v "^connected to:"
# Dump Redis
# cp /var/lib/redis/dump.rdb /home/backup/
# Dump MBR / table partitions
# dd if=/dev/sda of=/home/backup/MBR bs=512 count=1 2>&1 | egrep -v "(records in|records out|512 bytes)"
# sfdisk -d /dev/sda > /home/backup/partitions 2>&1 | egrep -v "(Warning: extended partition does not start at a cylinder boundary|DOS and Linux will interpret the contents differently)"
# Dump routes
# traceroute -n 8.8.8.8 > /home/backup/traceroute-8.8.8.8
# mtr -r 8.8.8.8 > /home/backup/mtr-8.8.8.8
# traceroute -n backup.evolix.net > /home/backup/traceroute-backup.evolix.net
# mtr -r backup.evolix.net > /home/backup/mtr-backup.evolix.net
# traceroute -n www.evolix.fr > /home/backup/traceroute-www.evolix.fr
# mtr -r www.evolix.fr > /home/backup/mtr-www.evolix.fr
# traceroute -n www.evolix.net > /home/backup/traceroute-www.evolix.net
# mtr -r www.evolix.net > /home/backup/mtr-www.evolix.net
# Dump des processus
ps aux >/home/backup/ps.out
# Dump des connexions reseaux en cours
netstat -taupen >/home/backup/netstat.out
# Liste des paquets installes
dpkg -l >/home/backup/packages
HOSTNAME=$(hostname)
DATE=$(/bin/date +"%d-%m-%Y")
DEBUT=$(/bin/date +"%d-%m-%Y ; %H:%M")
if [ $SYSTEME = "linux" ]; then
rep="/bin /boot /lib /opt /sbin /usr"
else
rep="/bsd /bin /boot /sbin /usr"
fi
rsync -av --delete --force --ignore-errors --partial \
--exclude "lost+found" \
--exclude ".nfs.*" \
--exclude "/var/log" \
--exclude "/var/log/evobackup*" \
--exclude "/var/lib/mysql" \
--exclude "/var/lib/postgres" \
--exclude "/var/lib/postgresql" \
--exclude "/var/lib/sympa" \
--exclude "/var/lib/metche" \
--exclude "/var/run" \
--exclude "/var/lock" \
--exclude "/var/state" \
--exclude "/var/apt" \
--exclude "/var/cache" \
--exclude "/usr/src" \
--exclude "/usr/doc" \
--exclude "/usr/share/doc" \
--exclude "/usr/obj" \
--exclude "dev" \
--exclude "/var/spool/postfix" \
--exclude "/var/lib/amavis/amavisd.sock" \
--exclude "/var/lib/munin/munin-update.stats.tmp" \
--exclude "/var/lib/php5" \
--exclude "/var/spool/squid" \
$rep \
/etc \
/root \
/var \
/home \
/srv \
-e "ssh -p $SSH_PORT" \
root@node$NODE.backup.example.com:/var/backup/ \
| tail -20 >> /var/log/evobackup.log
FIN=$(/bin/date +"%d-%m-%Y ; %H:%M")
echo "EvoBackup - $HOSTNAME - START $DEBUT" \
>> /var/log/evobackup.log
echo "EvoBackup - $HOSTNAME - STOP $FIN" \
>> /var/log/evobackup.log
tail -10 /var/log/evobackup.log | \
mail -s "[info] EvoBackup - Client $HOSTNAME" \
$MAIL