rsnapshot
Unterschiede
Hier werden die Unterschiede zwischen zwei Versionen angezeigt.
| Beide Seiten der vorigen RevisionVorhergehende Überarbeitung | |||
| rsnapshot [2017-02-22 16:53:56] – manfred | rsnapshot [2017-02-23 08:00:42] (aktuell) – manfred | ||
|---|---|---|---|
| Zeile 1: | Zeile 1: | ||
| + | ====== rsnapshot ====== | ||
| + | |||
| + | * [[http:// | ||
| + | * [[https:// | ||
| + | * [[http:// | ||
| + | |||
| + | ==== MySQL-Sicherung per LVM-SnapShot ==== | ||
| + | |||
| + | root@dbhost: | ||
| + | LV | ||
| + | backup backup -wi-ao--- 1000,00g | ||
| + | mysql trusty -wi-ao--- | ||
| + | root | ||
| + | swap | ||
| + | |||
| + | root@dbhost: | ||
| + | Filesystem | ||
| + | udev | ||
| + | tmpfs 799M 444K 798M 1% /run | ||
| + | / | ||
| + | none | ||
| + | none | ||
| + | none | ||
| + | none | ||
| + | / | ||
| + | / | ||
| + | / | ||
| + | |||
| + | <file bash / | ||
| + | # Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. | ||
| + | # | ||
| + | # 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; version 2 of the License. | ||
| + | # | ||
| + | # 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. | ||
| + | # 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 St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| + | |||
| + | # | ||
| + | # The MySQL Server configuration file. | ||
| + | # | ||
| + | # For explanations see | ||
| + | # http:// | ||
| + | |||
| + | [mysqld] | ||
| + | pid-file | ||
| + | socket | ||
| + | # | ||
| + | datadir | ||
| + | log-error | ||
| + | # By default we only accept connections from localhost | ||
| + | bind-address | ||
| + | # Disabling symbolic-links is recommended to prevent assorted security risks | ||
| + | symbolic-links | ||
| + | </ | ||
| + | |||
| + | <file bash / | ||
| + | ################################################# | ||
| + | # rsnapshot.conf - rsnapshot configuration file # | ||
| + | ################################################# | ||
| + | # # | ||
| + | # PLEASE BE AWARE OF THE FOLLOWING RULES: | ||
| + | # # | ||
| + | # This file requires tabs between elements | ||
| + | # # | ||
| + | # Directories require a trailing slash: | ||
| + | # | ||
| + | # | ||
| + | # # | ||
| + | ################################################# | ||
| + | |||
| + | ####################### | ||
| + | # CONFIG FILE VERSION # | ||
| + | ####################### | ||
| + | |||
| + | config_version | ||
| + | |||
| + | ########################### | ||
| + | # SNAPSHOT ROOT DIRECTORY # | ||
| + | ########################### | ||
| + | |||
| + | # All snapshots will be stored under this root directory. | ||
| + | # | ||
| + | # | ||
| + | snapshot_root | ||
| + | |||
| + | # If no_create_root is enabled, rsnapshot will not automatically create the | ||
| + | # snapshot_root directory. This is particularly useful if you are backing | ||
| + | # up to removable media, such as a FireWire or USB drive. | ||
| + | # | ||
| + | no_create_root | ||
| + | |||
| + | ################################# | ||
| + | # EXTERNAL PROGRAM DEPENDENCIES # | ||
| + | ################################# | ||
| + | |||
| + | # LINUX USERS: | ||
| + | # EVERYONE ELSE: Leave " | ||
| + | # | ||
| + | # See the README file or the man page for more details. | ||
| + | # | ||
| + | cmd_cp | ||
| + | |||
| + | # uncomment this to use the rm program instead of the built-in perl routine. | ||
| + | # | ||
| + | cmd_rm | ||
| + | |||
| + | # rsync must be enabled for anything to work. This is the only command that | ||
| + | # must be enabled. | ||
| + | # | ||
| + | cmd_rsync | ||
| + | |||
| + | # Uncomment this to enable remote ssh backups over rsync. | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Comment this out to disable syslog support. | ||
| + | # | ||
| + | cmd_logger | ||
| + | |||
| + | # Uncomment this to specify the path to " | ||
| + | # If you have an older version of " | ||
| + | # " | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Uncomment this to specify the path to rsnapshot-diff. | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Specify the path to a script (and any optional arguments) to run right | ||
| + | # before rsnapshot syncs files | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Specify the path to a script (and any optional arguments) to run right | ||
| + | # after rsnapshot syncs files | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Paths to lvcreate, lvremove, mount and umount commands, for use with | ||
| + | # Linux LVMs. | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | |||
| + | ######################################### | ||
| + | # | ||
| + | # Must be unique and in ascending order # | ||
| + | # i.e. hourly, daily, weekly, etc. # | ||
| + | ######################################### | ||
| + | |||
| + | retain | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | |||
| + | ############################################ | ||
| + | # GLOBAL OPTIONS | ||
| + | # All are optional, with sensible defaults # | ||
| + | ############################################ | ||
| + | |||
| + | # Verbose level, 1 through 5. | ||
| + | # 1 | ||
| + | # 2 | ||
| + | # 3 | ||
| + | # 4 Extra Verbose | ||
| + | # 5 Debug mode Everything | ||
| + | # | ||
| + | verbose | ||
| + | |||
| + | # Same as " | ||
| + | # logfile, if one is being used. The default is 3. | ||
| + | # | ||
| + | loglevel | ||
| + | |||
| + | # If you enable this, data will be written to the file you specify. The | ||
| + | # amount of data written is controlled by the " | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # If enabled, rsnapshot will write a lockfile to prevent two instances | ||
| + | # from running simultaneously (and messing up the snapshot_root). | ||
| + | # If you enable this, make sure the lockfile directory is not world | ||
| + | # writable. Otherwise anyone can prevent the program from running. | ||
| + | # | ||
| + | lockfile | ||
| + | |||
| + | # By default, rsnapshot check lockfile, check if PID is running | ||
| + | # and if not, consider lockfile as stale, then start | ||
| + | # Enabling this stop rsnapshot if PID in lockfile is not running | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Default rsync args. All rsync commands have at least these options set. | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # ssh has no args passed by default, but you can specify some here. | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Default arguments for the " | ||
| + | # The GNU version of " | ||
| + | # If your version of " | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # If this is enabled, rsync won't span filesystem partitions within a | ||
| + | # backup point. This essentially passes the -x option to rsync. | ||
| + | # The default is 0 (off). | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # The include and exclude parameters, if enabled, simply get passed directly | ||
| + | # to rsync. If you have multiple include/ | ||
| + | # separate line. Please look up the --include and --exclude options in the | ||
| + | # rsync man page for more details on how to specify file name patterns. | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # The include_file and exclude_file parameters, if enabled, simply get | ||
| + | # passed directly to rsync. Please look up the --include-from and | ||
| + | # --exclude-from options in the rsync man page for more details. | ||
| + | # | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # If your version of rsync supports --link-dest, | ||
| + | # This is the best way to support special files (FIFOs, etc) cross-platform. | ||
| + | # The default is 0 (off). | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # When sync_first is enabled, it changes the default behaviour of rsnapshot. | ||
| + | # Normally, when rsnapshot is called with its lowest interval | ||
| + | # (i.e.: " | ||
| + | # intervals. With sync_first enabled, " | ||
| + | # and all interval calls simply rotate files. See the man page for more | ||
| + | # details. The default is 0 (off). | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # If enabled, rsnapshot will move the oldest directory for each interval | ||
| + | # to [interval_name].delete, | ||
| + | # that directory just before it exits. The default is 0 (off). | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Number of rsync re-tries. If you experience any network problems or | ||
| + | # network card issues that tend to cause ssh to crap-out with | ||
| + | # " | ||
| + | # value to have the rsync operation re-tried | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # LVM parameters. Used to backup with creating lvm snapshot before backup | ||
| + | # and removing it after. This should ensure consistency of data in some special | ||
| + | # cases | ||
| + | # | ||
| + | # LVM snapshot(s) size (lvcreate --size option). | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Name to be used when creating the LVM logical volume snapshot(s). | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Path to the LVM Volume Groups. | ||
| + | # | ||
| + | # | ||
| + | |||
| + | # Mount point to use to temporarily mount the snapshot(s). | ||
| + | # | ||
| + | # | ||
| + | |||
| + | ############################### | ||
| + | ### BACKUP POINTS / SCRIPTS ### | ||
| + | ############################### | ||
| + | |||
| + | # LOCALHOST | ||
| + | backup | ||
| + | backup | ||
| + | #backup / | ||
| + | #backup /etc/ | ||
| + | #backup / | ||
| + | #backup / | ||
| + | #backup / | ||
| + | #backup / | ||
| + | #backup / | ||
| + | # | ||
| + | # You must set linux_lvm_* parameters below before using lvm snapshots | ||
| + | #backup lvm:// | ||
| + | |||
| + | # EXAMPLE.COM | ||
| + | # | ||
| + | #backup root@example.com:/ | ||
| + | #backup root@example.com:/ | ||
| + | # | ||
| + | #backup root@example.com:/ | ||
| + | # | ||
| + | |||
| + | # CVS.SOURCEFORGE.NET | ||
| + | # | ||
| + | |||
| + | # RSYNC.SAMBA.ORG | ||
| + | #backup rsync:// | ||
| + | </ | ||
| + | |||
| + | <file bash / | ||
| + | #!/bin/bash | ||
| + | |||
| + | # | ||
| + | # MySQL-Backup mit LVM-SnapShot | ||
| + | # | ||
| + | |||
| + | # | ||
| + | # | ||
| + | # https:// | ||
| + | # | ||
| + | # | ||
| + | # LVM2, und rsnapshot muss installiert sein | ||
| + | # aptitude install lvm2 rsnapshot | ||
| + | # eine Volumengruppe muss angelegt sein, | ||
| + | # in der das zu sichernde Laufwerk liegt und soviel freier Platz ist, | ||
| + | # wie temporär für die Backup-Zeit benötigt werden. | ||
| + | # | ||
| + | VERSION=" | ||
| + | # | ||
| + | # / | ||
| + | # / | ||
| + | # | ||
| + | SNAPSHOT="/ | ||
| + | VolumenGruppe=" | ||
| + | VolumenName=" | ||
| + | # | ||
| + | |||
| + | BACKUP=Ja | ||
| + | umount / | ||
| + | umount ${SNAPSHOT} 2>/ | ||
| + | |||
| + | echo "FLUSH TABLES WITH READ LOCK;" | mysql -t || export BACKUP=Nein | ||
| + | echo "SHOW MASTER STATUS; SHOW SLAVE HOSTS; SHOW SLAVE STATUS \G;" | mysql -t > / | ||
| + | # modprobe dm-snapshot | ||
| + | lvcreate -l 100%FREE -s -n ${VolumenName}backup / | ||
| + | echo " | ||
| + | |||
| + | mount / | ||
| + | mount / | ||
| + | |||
| + | if [ " | ||
| + | # | ||
| + | # Copy data to backup | ||
| + | rsnapshot hourly | ||
| + | # | ||
| + | fi | ||
| + | |||
| + | ls -lha / | ||
| + | umount / | ||
| + | umount ${SNAPSHOT} | ||
| + | lvremove -f / | ||
| + | </ | ||
