mirror of
https://github.com/pikami/sysadmin.git
synced 2024-11-24 12:45:45 +00:00
Create make-backup.sh
This commit is contained in:
parent
eba6b037cc
commit
527adc8555
32
backup/make-backup.sh
Normal file
32
backup/make-backup.sh
Normal file
@ -0,0 +1,32 @@
|
||||
#!/bin/bash
|
||||
DATE=$(date +"%d-%m-%Y")
|
||||
BACKUP_DIR='/home/backuper/backups'
|
||||
DIRS_TO_BACKUP=(
|
||||
# Mail
|
||||
'/etc/;postfix' # postfix configs
|
||||
'/etc/;dovecot' # dovecot configs
|
||||
'/var/;mail' # emails
|
||||
# Web
|
||||
'/etc/;nginx' # nginx configs
|
||||
'/var/;www' # websites
|
||||
)
|
||||
|
||||
# Setup
|
||||
mkdir -p $BACKUP_DIR/mysql
|
||||
|
||||
# Backup directories
|
||||
for i in "${DIRS_TO_BACKUP[@]}"
|
||||
do
|
||||
conf=(${i//;/ })
|
||||
echo ${conf[0]}
|
||||
echo ${conf[1]}
|
||||
tar -zcvf $BACKUP_DIR/${conf[1]}-$DATE.tgz -C ${conf[0]} ${conf[1]}
|
||||
done
|
||||
|
||||
# SQL
|
||||
mysql -N -e 'show databases' | while read dbname;
|
||||
do
|
||||
mysqldump --complete-insert --routines --triggers --single-transaction "$dbname" > $BACKUP_DIR/mysql/"$dbname".sql;
|
||||
done
|
||||
tar -zcvf $BACKUP_DIR/mysql-$DATE.tgz -C $BACKUP_DIR/ mysql
|
||||
rm -rf $BACKUP_DIR/mysql
|
Loading…
Reference in New Issue
Block a user