forked from evolix/evobackup
- use only english in comments
- improve comments
This commit is contained in:
parent
0fcc2478c4
commit
1b02ba0a70
|
@ -1,15 +1,15 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
#
|
#
|
||||||
# Script evobackup client
|
# Script Evobackup client
|
||||||
# $Id: evobackup_cron_daily_client,v 1.21 2010-08-22 10:15:42 gcolpart Exp $
|
# See https://forge.evolix.org/projects/evobackup
|
||||||
#
|
#
|
||||||
|
|
||||||
# lang = C pour gerer les outputs en anglais
|
## lang = C for english outputs
|
||||||
LANGUAGE=C
|
LANGUAGE=C
|
||||||
LANG=C
|
LANG=C
|
||||||
|
|
||||||
# Verification qu'un autre evobackup n'est pas deja lance
|
## Verify other evobackup process and kill if needed
|
||||||
PIDFILE=/var/run/evobackup.pid
|
PIDFILE=/var/run/evobackup.pid
|
||||||
if [ -e $PIDFILE ]; then
|
if [ -e $PIDFILE ]; then
|
||||||
# Killing the childs of evobackup.
|
# Killing the childs of evobackup.
|
||||||
|
@ -24,53 +24,56 @@ echo "$$" > $PIDFILE
|
||||||
trap "rm -f $PIDFILE" EXIT
|
trap "rm -f $PIDFILE" EXIT
|
||||||
|
|
||||||
# port SSH
|
# port SSH
|
||||||
SSH_PORT=2228
|
SSH_PORT=2XXX
|
||||||
|
|
||||||
# systeme de la machine ("linux" ou "bsd")
|
# choose "linux" or "bsd"
|
||||||
SYSTEME=linux
|
SYSTEME=linux
|
||||||
|
|
||||||
# mail de remontee
|
# email adress for notifications
|
||||||
MAIL=jdoe@example.com
|
MAIL=jdoe@example.com
|
||||||
|
|
||||||
|
# Variable to choose different backup server with date
|
||||||
NODE=$(expr `date +%d` % 2)
|
NODE=$(expr `date +%d` % 2)
|
||||||
|
|
||||||
# operations specifiques
|
|
||||||
|
|
||||||
|
## We use /home/backup : feel free to use your own dir
|
||||||
mkdir -p -m 700 /home/backup
|
mkdir -p -m 700 /home/backup
|
||||||
|
|
||||||
# Dump LDAP
|
## OpenLDAP : example with slapcat
|
||||||
# slapcat -l /home/backup/ldap.bak
|
# slapcat -l /home/backup/ldap.bak
|
||||||
|
|
||||||
# Dump MySQL
|
### MySQL
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf \
|
|
||||||
|
## example with global and compressed mysqldump
|
||||||
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 \
|
||||||
# --opt --all-databases --force --events --hex-blob | gzip --best > /home/backup/mysql.bak.gz
|
# --opt --all-databases --force --events --hex-blob | gzip --best > /home/backup/mysql.bak.gz
|
||||||
|
|
||||||
# Dump des BDD en .sql.gz
|
## example with two dumps for each table (.sql/.txt) for all databases
|
||||||
# mkdir -p /home/mysqldump/
|
# for i in $(echo SHOW DATABASES | mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 \
|
||||||
# for i in $(mysql -e 'show databases' -s --skip-column-names | egrep -v "^(Database|information_schema|performance_schema)"); do
|
# | egrep -v "^(Database|information_schema|performance_schema)" ); \
|
||||||
# mysqldump --force --events --hex-blob $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 -RL mysql /home/mysqldump ; \
|
# do mkdir -p /home/mysqldump/$i ; chown -RL mysql /home/mysqldump ; \
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q --opt --events --hex-blob --skip-comments -T \
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 -Q --opt --events --hex-blob --skip-comments -T \
|
||||||
# /home/mysqldump/$i $i; done
|
# /home/mysqldump/$i $i; done
|
||||||
|
|
||||||
# Dump par base
|
## example with compressed SQL dump for each databases
|
||||||
# mkdir -p -m 700 /home/mysqldump/BASE
|
# mkdir -p /home/mysqldump/
|
||||||
|
# for i in $(mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 -e 'show databases' -s --skip-column-names \
|
||||||
|
# | egrep -v "^(Database|information_schema|performance_schema)"); do
|
||||||
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -P 3306 --events --hex-blob $i | gzip --best > /home/mysqldump/${i}.sql.gz
|
||||||
|
# done
|
||||||
|
|
||||||
|
## example with *one* uncompressed SQL dump for *one* database (MYBASE)
|
||||||
|
# mkdir -p -m 700 /home/mysqldump/MYBASE
|
||||||
# chown -RL mysql /home/mysqldump/
|
# chown -RL mysql /home/mysqldump/
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q \
|
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf --force -Q \
|
||||||
# --opt --events --hex-blob --skip-comments -T /home/mysqldump/BASE BASE
|
# --opt --events --hex-blob --skip-comments -T /home/mysqldump/MYBASE MYBASE
|
||||||
|
|
||||||
|
## example with mysqlhotcopy
|
||||||
# mkdir -p /home/mysqlhotcopy/
|
# mkdir -p /home/mysqlhotcopy/
|
||||||
# mysqlhotcopy BASE /home/mysqlhotcopy/
|
# mysqlhotcopy BASE /home/mysqlhotcopy/
|
||||||
|
|
||||||
# Dump instanceS MySQL
|
## example for multiples MySQL instances
|
||||||
#
|
|
||||||
## Recherche du mot de passe mysqladmin
|
|
||||||
# mysqladminpasswd=`cat /root/.my.cnf |grep -m1 'password = .*' |cut -d" " -f3`
|
# 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
|
# grep -E "^port\s*=\s*\d*" /etc/mysql/my.cnf |while read instance; do
|
||||||
# instance=$(echo $instance |tr -d '\t')
|
# instance=$(echo $instance |tr -d '\t')
|
||||||
# instance=${instance// /}
|
# instance=${instance// /}
|
||||||
|
@ -81,27 +84,28 @@ mkdir -p -m 700 /home/backup
|
||||||
# fi
|
# fi
|
||||||
# done
|
# done
|
||||||
|
|
||||||
|
### PostgreSQL
|
||||||
|
|
||||||
# Dump PostgreSQL
|
## example with pg_dumpall (warning: you need space in ~postgres)
|
||||||
# su - postgres -c "pg_dumpall > ~/pg.dump.bak"
|
# su - postgres -c "pg_dumpall > ~/pg.dump.bak"
|
||||||
# mv ~postgres/pg.dump.bak /home/backup/
|
# mv ~postgres/pg.dump.bak /home/backup/
|
||||||
|
|
||||||
# Exemple de backups...
|
## example with all tables from MYBASE excepts TABLE1 and TABLE2
|
||||||
# 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' MYBASE
|
||||||
# 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
|
## example with only TABLE1 and TABLE2 from MYBASE
|
||||||
# Creation d'un utilisateur en lecture seule :
|
# 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' MYBASE
|
||||||
# > use admin
|
|
||||||
# > db.addUser("mongobackup", "PASS", true);
|
## MongoDB : example with mongodump
|
||||||
|
## don't forget to create use with read-only access
|
||||||
|
## > use admin
|
||||||
|
## > db.addUser("mongobackup", "PASS", true);
|
||||||
# mongodump -u mongobackup -pPASS -o /home/backup/mongodump/ >/dev/null 2>&1 |grep -v "^connected to:"
|
# mongodump -u mongobackup -pPASS -o /home/backup/mongodump/ >/dev/null 2>&1 |grep -v "^connected to:"
|
||||||
|
|
||||||
# Dump Redis
|
## Redis : example with copy .rdb file
|
||||||
# cp /var/lib/redis/dump.rdb /home/backup/
|
# cp /var/lib/redis/dump.rdb /home/backup/
|
||||||
|
|
||||||
## Dump ElasticSearch
|
## ElasticSearch : example with rsync (warning: don't forget to use NFS if you have a cluster)
|
||||||
## Disable ES translog flush
|
## Disable ES translog flush
|
||||||
# curl -s -XPUT 'localhost:9200/_settings' -d '{"index.translog.disable_flush": true}' >/dev/null
|
# curl -s -XPUT 'localhost:9200/_settings' -d '{"index.translog.disable_flush": true}' >/dev/null
|
||||||
## Flushes translog
|
## Flushes translog
|
||||||
|
@ -115,25 +119,26 @@ mkdir -p -m 700 /home/backup
|
||||||
## In any case re-enable translog flush
|
## In any case re-enable translog flush
|
||||||
# curl -s -XPUT 'localhost:9200/_settings' -d '{"index.translog.disable_flush": false}' > /dev/null
|
# curl -s -XPUT 'localhost:9200/_settings' -d '{"index.translog.disable_flush": false}' > /dev/null
|
||||||
|
|
||||||
# Dump MBR / table partitions
|
## Dump MBR / table partitions with dd and sfdisk
|
||||||
# dd if=/dev/sda of=/home/backup/MBR bs=512 count=1 2>&1 | egrep -v "(records in|records out|512 bytes)"
|
# 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)"
|
# 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
|
## Dump network routes with mtr and traceroute (warning: could be long with aggressive firewalls)
|
||||||
for addr in 8.8.8.8 backup.evolix.net www.evolix.fr www.evolix.net; do
|
for addr in 8.8.8.8 backup.evolix.net www.evolix.fr www.evolix.net; do
|
||||||
mtr -r $addr > /home/backup/mtr-${addr}
|
mtr -r $addr > /home/backup/mtr-${addr}
|
||||||
traceroute -n $addr > /home/backup/traceroute-${addr}
|
traceroute -n $addr > /home/backup/traceroute-${addr}
|
||||||
done
|
done
|
||||||
|
|
||||||
# Dump des processus
|
## Dump process with ps
|
||||||
ps aux >/home/backup/ps.out
|
ps aux >/home/backup/ps.out
|
||||||
|
|
||||||
# Dump des connexions reseaux en cours
|
## Dump network connections with netstat
|
||||||
netstat -taupen >/home/backup/netstat.out
|
netstat -taupen >/home/backup/netstat.out
|
||||||
|
|
||||||
# Liste des paquets installes
|
## List Debian packages
|
||||||
dpkg -l >/home/backup/packages
|
dpkg -l >/home/backup/packages
|
||||||
|
|
||||||
|
|
||||||
HOSTNAME=$(hostname)
|
HOSTNAME=$(hostname)
|
||||||
|
|
||||||
DATE=$(/bin/date +"%d-%m-%Y")
|
DATE=$(/bin/date +"%d-%m-%Y")
|
||||||
|
|
Loading…
Reference in a new issue