Add a variable for local backup
This commit is contained in:
parent
125ca2c203
commit
5821e87e4b
|
@ -50,16 +50,17 @@ I=$((10#$(date +%d) % ${NB_NODES}))
|
||||||
SRV=${NODES[${I}]}
|
SRV=${NODES[${I}]}
|
||||||
|
|
||||||
## We use /home/backup : feel free to use your own dir
|
## We use /home/backup : feel free to use your own dir
|
||||||
mkdir -p -m 700 /home/backup
|
LOCAL_BACKUP_DIR=/home/backup
|
||||||
|
mkdir -p -m 700 "${LOCAL_BACKUP_DIR}"
|
||||||
|
|
||||||
## OpenLDAP : example with slapcat
|
## OpenLDAP : example with slapcat
|
||||||
# slapcat -l /home/backup/ldap.bak
|
# slapcat -l ${LOCAL_BACKUP_DIR}/ldap.bak
|
||||||
|
|
||||||
### MySQL
|
### MySQL
|
||||||
|
|
||||||
## example with global and compressed mysqldump
|
## example with global and compressed mysqldump
|
||||||
# mysqldump --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 \
|
# 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 > ${LOCAL_BACKUP_DIR}/mysql.bak.gz
|
||||||
|
|
||||||
## example with two dumps for each table (.sql/.txt) for all databases
|
## example with two dumps for each table (.sql/.txt) for all databases
|
||||||
# for i in $(echo SHOW DATABASES | mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 \
|
# for i in $(echo SHOW DATABASES | mysql --defaults-extra-file=/etc/mysql/debian.cnf -P 3306 \
|
||||||
|
@ -91,7 +92,7 @@ mkdir -p -m 700 /home/backup
|
||||||
# instance=$(echo "${instance}"|awk '{ print $3 }')
|
# instance=$(echo "${instance}"|awk '{ print $3 }')
|
||||||
# if [ "${instance}" != "3306" ]
|
# if [ "${instance}" != "3306" ]
|
||||||
# then
|
# then
|
||||||
# mysqldump -P ${instance} --opt --all-databases --hex-blob -u mysqladmin -p${mysqladminpasswd} > /home/backup/mysql.${instance}.bak
|
# mysqldump -P ${instance} --opt --all-databases --hex-blob -u mysqladmin -p${mysqladminpasswd} > ${LOCAL_BACKUP_DIR}/mysql.${instance}.bak
|
||||||
# fi
|
# fi
|
||||||
# done
|
# done
|
||||||
|
|
||||||
|
@ -99,29 +100,29 @@ mkdir -p -m 700 /home/backup
|
||||||
|
|
||||||
## example with pg_dumpall (warning: you need space in ~postgres)
|
## 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 ${LOCAL_BACKUP_DIR}/
|
||||||
## another method with gzip directly piped
|
## another method with gzip directly piped
|
||||||
# cd /var/lib/postgresql
|
# cd /var/lib/postgresql
|
||||||
# sudo -u postgres pg_dumpall | gzip > /home/backup/pg.dump.bak.gz
|
# sudo -u postgres pg_dumpall | gzip > ${LOCAL_BACKUP_DIR}/pg.dump.bak.gz
|
||||||
# cd - > /dev/null
|
# cd - > /dev/null
|
||||||
|
|
||||||
## example with all tables from MYBASE excepts TABLE1 and TABLE2
|
## example with all tables from MYBASE excepts TABLE1 and TABLE2
|
||||||
# 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 ${LOCAL_BACKUP_DIR}/pg-backup.tar -t 'TABLE1' -t 'TABLE2' MYBASE
|
||||||
|
|
||||||
## example with only TABLE1 and TABLE2 from MYBASE
|
## example with only TABLE1 and TABLE2 from 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' MYBASE
|
# pg_dump -p 5432 -h 127.0.0.1 -U USER --clean -F t --inserts -f ${LOCAL_BACKUP_DIR}/pg-backup.tar -T 'TABLE1' -T 'TABLE2' MYBASE
|
||||||
|
|
||||||
## MongoDB : example with mongodump
|
## MongoDB : example with mongodump
|
||||||
## don't forget to create use with read-only access
|
## don't forget to create use with read-only access
|
||||||
## > use admin
|
## > use admin
|
||||||
## > db.createUser( { user: "mongobackup", pwd: "PASS", roles: [ "backup", ] } )
|
## > db.createUser( { user: "mongobackup", pwd: "PASS", roles: [ "backup", ] } )
|
||||||
# mongodump --quiet -u mongobackup -pPASS -o /home/backup/mongodump/
|
# mongodump --quiet -u mongobackup -pPASS -o ${LOCAL_BACKUP_DIR}/mongodump/
|
||||||
# if [ $? -ne 0 ]; then
|
# if [ $? -ne 0 ]; then
|
||||||
# echo "Error with mongodump!"
|
# echo "Error with mongodump!"
|
||||||
# fi
|
# fi
|
||||||
|
|
||||||
## Redis : example with copy .rdb file
|
## Redis : example with copy .rdb file
|
||||||
# cp /var/lib/redis/dump.rdb /home/backup/
|
# cp /var/lib/redis/dump.rdb ${LOCAL_BACKUP_DIR}/
|
||||||
|
|
||||||
## ElasticSearch : example with rsync (warning: don't forget to use NFS if you have a cluster)
|
## ElasticSearch : example with rsync (warning: don't forget to use NFS if you have a cluster)
|
||||||
## Disable ES translog flush
|
## Disable ES translog flush
|
||||||
|
@ -130,7 +131,7 @@ mkdir -p -m 700 /home/backup
|
||||||
# curl -s 'localhost:9200/_flush' | grep -qe '"ok":true'
|
# curl -s 'localhost:9200/_flush' | grep -qe '"ok":true'
|
||||||
## If it succeed, do an rsync of the datadir
|
## If it succeed, do an rsync of the datadir
|
||||||
# if [ $? -eq 0 ]; then
|
# if [ $? -eq 0 ]; then
|
||||||
# rsync -a /var/lib/elasticsearch /home/backup/
|
# rsync -a /var/lib/elasticsearch ${LOCAL_BACKUP_DIR}/
|
||||||
# else
|
# else
|
||||||
# echo "Error when flushing ES translog indexes."
|
# echo "Error when flushing ES translog indexes."
|
||||||
# fi
|
# fi
|
||||||
|
@ -138,47 +139,47 @@ mkdir -p -m 700 /home/backup
|
||||||
# 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
|
||||||
|
|
||||||
## RabbitMQ : export config
|
## RabbitMQ : export config
|
||||||
#rabbitmqadmin export /home/backup/rabbitmq.config >> /var/log/evobackup.log
|
#rabbitmqadmin export ${LOCAL_BACKUP_DIR}/rabbitmq.config >> /var/log/evobackup.log
|
||||||
|
|
||||||
## Dump MBR / table partitions with dd and sfdisk
|
## Dump MBR / table partitions with dd and sfdisk
|
||||||
## Linux
|
## Linux
|
||||||
#for disk in $(ls /dev/[sv]d[a-z] 2>/dev/null); do
|
#for disk in $(ls /dev/[sv]d[a-z] 2>/dev/null); do
|
||||||
# name=$(basename ${disk})
|
# name=$(basename ${disk})
|
||||||
# dd if=${disk} of=/home/backup/MBR-${name} bs=512 count=1 2>&1 | egrep -v "(records in|records out|512 bytes)"
|
# dd if=${disk} of=${LOCAL_BACKUP_DIR}/MBR-${name} bs=512 count=1 2>&1 | egrep -v "(records in|records out|512 bytes)"
|
||||||
# fdisk -l ${disk} > /home/backup/partitions-${name}
|
# fdisk -l ${disk} > ${LOCAL_BACKUP_DIR}/partitions-${name}
|
||||||
#done
|
#done
|
||||||
#cat /home/backup/partitions-* > /home/backup/partitions
|
#cat ${LOCAL_BACKUP_DIR}/partitions-* > ${LOCAL_BACKUP_DIR}/partitions
|
||||||
## OpenBSD
|
## OpenBSD
|
||||||
# disklabel sd0 > /home/backup/partitions
|
# disklabel sd0 > ${LOCAL_BACKUP_DIR}/partitions
|
||||||
|
|
||||||
# backup MegaCli config
|
# backup MegaCli config
|
||||||
#megacli -CfgSave -f /home/backup/megacli_conf.dump -a0 >/dev/null
|
#megacli -CfgSave -f ${LOCAL_BACKUP_DIR}/megacli_conf.dump -a0 >/dev/null
|
||||||
|
|
||||||
## Dump system and kernel versions
|
## Dump system and kernel versions
|
||||||
uname -a > /home/backup/uname
|
uname -a > ${LOCAL_BACKUP_DIR}/uname
|
||||||
|
|
||||||
## Dump network routes with mtr and traceroute (warning: could be long with aggressive firewalls)
|
## Dump network routes with mtr and traceroute (warning: could be long with aggressive firewalls)
|
||||||
for addr in 8.8.8.8 www.evolix.fr travaux.evolix.net; do
|
for addr in 8.8.8.8 www.evolix.fr travaux.evolix.net; do
|
||||||
mtr -r ${addr} > /home/backup/mtr-${addr}
|
mtr -r ${addr} > ${LOCAL_BACKUP_DIR}/mtr-${addr}
|
||||||
traceroute -n ${addr} > /home/backup/traceroute-${addr}
|
traceroute -n ${addr} > ${LOCAL_BACKUP_DIR}/traceroute-${addr}
|
||||||
done
|
done
|
||||||
|
|
||||||
## Dump process with ps
|
## Dump process with ps
|
||||||
ps aux >/home/backup/ps.out
|
ps aux >${LOCAL_BACKUP_DIR}/ps.out
|
||||||
|
|
||||||
if [ "${SYSTEM}" = "linux" ]; then
|
if [ "${SYSTEM}" = "linux" ]; then
|
||||||
## Dump network connections with netstat
|
## Dump network connections with netstat
|
||||||
netstat -taupen >/home/backup/netstat.out
|
netstat -taupen >${LOCAL_BACKUP_DIR}/netstat.out
|
||||||
|
|
||||||
## List Debian packages
|
## List Debian packages
|
||||||
dpkg -l >/home/backup/packages
|
dpkg -l >${LOCAL_BACKUP_DIR}/packages
|
||||||
dpkg --get-selections >/home/backup/packages.getselections
|
dpkg --get-selections >${LOCAL_BACKUP_DIR}/packages.getselections
|
||||||
else
|
else
|
||||||
## Dump network connections with netstat
|
## Dump network connections with netstat
|
||||||
netstat -finet -atn >/home/backup/netstat.out
|
netstat -finet -atn >${LOCAL_BACKUP_DIR}/netstat.out
|
||||||
|
|
||||||
## List OpenBSD packages
|
## List OpenBSD packages
|
||||||
pkg_info -m >/home/backup/packages
|
pkg_info -m >${LOCAL_BACKUP_DIR}/packages
|
||||||
fi
|
fi
|
||||||
|
|
||||||
HOSTNAME=$(hostname)
|
HOSTNAME=$(hostname)
|
||||||
|
|
Loading…
Reference in a new issue