@@ -0,0 +1,17 @@ | |||||
#!/bin/bash | |||||
# Variables | |||||
BACKUP_ROOT_FILES="/backup/files" | |||||
BACKUP_FILES_RETENTION=10 | |||||
# Starting backup | |||||
echo "Starting files backup process ..." | |||||
# Backup server configuration | |||||
mkdir -p ${BACKUP_ROOT_FILES} | |||||
HOUR=`date +%Y%m%d%H%M` | |||||
tar czf ${BACKUP_ROOT_FILES}/files_${HOUR}.tar.gz /etc | |||||
# Purge old backup | |||||
echo "Starting files purge process for backup older than ${BACKUP_PRODUCTS_RETENTION} ..." | |||||
find ${BACKUP_ROOT_FILES} -type f -mtime +${BACKUP_FILES_RETENTION} -exec rm -f {} \; |
@@ -0,0 +1,26 @@ | |||||
#!/bin/bash | |||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S) | |||||
BACKUP_ROOT_LDAP=/backup/ldap | |||||
BACKUP_PATH_LDAP=${BACKUP_ROOT_LDAP}/${TIMESTAMP} | |||||
BACKUP_LDAP_RETENTION=10 | |||||
# Let's go ! | |||||
echo "Starting ldap backup process ..." | |||||
# Backup server configuration | |||||
mkdir -p ${BACKUP_PATH_LDAP} | |||||
/usr/bin/nice /usr/sbin/slapcat -n 0 > ${BACKUP_PATH_LDAP}/config.ldif | |||||
/usr/bin/nice /usr/sbin/slapcat -n 1 > ${BACKUP_PATH_LDAP}/domain.ldif | |||||
chmod 640 ${BACKUP_PATH_LDAP}/*.ldif | |||||
tar cpzf ${BACKUP_PATH_LDAP}/etc_ldap.tgz /etc/ldap >/dev/null 2>&1 | |||||
tar cpzf ${BACKUP_PATH_LDAP}/var_lib_ldap.tgz /var/lib/ldap >/dev/null 2>&1 | |||||
HOUR=`date +%Y%m%d%H%M` | |||||
tar czf ${BACKUP_ROOT_LDAP}/ldap_${HOUR}.tar.gz ${BACKUP_PATH_LDAP} && rm -rf ${BACKUP_PATH_LDAP} | |||||
# Purge old backup | |||||
echo "Starting ldap purge process for backup older than ${BACKUP_PRODUCTS_RETENTION} ..." | |||||
find ${BACKUP_ROOT_LDAP} -type f -mtime +${BACKUP_LDAP_RETENTION} -exec rm -f {} \; |
@@ -0,0 +1,27 @@ | |||||
#!/bin/bash | |||||
# Variables | |||||
MAIL_ROOT="/var/mail" | |||||
BACKUP_ROOT_MAIL="/backup/mail" | |||||
BACKUP_MAIL_RETENTION=31 | |||||
# Starting mail backup | |||||
echo "Starting mail backup process ..." | |||||
# Create directories if not exists | |||||
mkdir -p ${BACKUP_ROOT_MAIL} | |||||
HOUR=`date +%Y%m%d%H%M` | |||||
# Create archive | |||||
for domain in `ls ${MAIL_ROOT}`; | |||||
do | |||||
mkdir -p ${BACKUP_ROOT_MAIL}/${domain} | |||||
for account in `ls ${MAIL_ROOT}/${domain}`; | |||||
do | |||||
tar czf ${BACKUP_ROOT_MAIL}/${domain}/${account}\_${HOUR}.tar.gz ${MAIL_ROOT}/${domain}/${account} | |||||
done | |||||
done | |||||
# Purge old backup | |||||
echo "Starting mail purge process for backup older than ${BACKUP_MAIL_RETENTION} ..." | |||||
find ${BACKUP_ROOT_MAIL} -type f -mtime +${BACKUP_MAIL_RETENTION} -exec rm -f {} \; |
@@ -0,0 +1,31 @@ | |||||
#!/bin/bash | |||||
# Variables | |||||
BACKUP_ROOT_MYSQL="/backup/mysql" | |||||
MYSQL_BIN=/usr/bin/mysql | |||||
MYSQLDUMP_BIN=/usr/bin/mysqldump | |||||
MYSQL_USER=backupuser | |||||
MYSQL_PASSWORD=backuppwd | |||||
GZIP_BIN=/bin/gzip | |||||
BACKUP_ROOT_MYSQL_RETENTION=10 | |||||
# Starting backup | |||||
echo "Starting MariaDB backup database process ..." | |||||
# Create directories if not exists | |||||
mkdir -p ${BACKUP_ROOT_MYSQL} | |||||
HOUR=`date +%Y%m%d%H%M` | |||||
# Backup with dump the structure | |||||
DATABASES=`${MYSQL_BIN} -u${MYSQL_USER} -p${MYSQL_PASSWORD} -e 'SHOW DATABASES' | grep -v - | grep -v Database | grep -v information_schema | grep -v performance_schema | grep -v \|` | |||||
for DB in $DATABASES; | |||||
do | |||||
${MYSQLDUMP_BIN} -u ${MYSQL_USER} -p${MYSQL_PASSWORD} ${DB} | ${GZIP_BIN} > ${BACKUP_ROOT_MYSQL}/${DB}_${HOUR}.sql.gz | |||||
if [ $? -ne 0 ]; then | |||||
echo "ERROR - Dump for ${DB}" | |||||
fi | |||||
done | |||||
# Purge old backup | |||||
echo "Starting MariaDB purge database process ..." | |||||
find ${BACKUP_ROOT_MYSQL} -type f -mtime +${BACKUP_ROOT_MYSQL_RETENTION} -exec rm -f {} \; |
@@ -0,0 +1,26 @@ | |||||
#!/bin/bash | |||||
# Variables | |||||
WEBSITES="/var/www" | |||||
BACKUP_ROOT_WEBSITES="/backup/websites" | |||||
BACKUP_WEBSITES_RETENTION=10 | |||||
# Starting websites backup | |||||
echo "Starting websites backup process ..." | |||||
# Create directories if not exists | |||||
mkdir -p ${BACKUP_ROOT_WEBSITES} | |||||
HOUR=`date +%Y%m%d%H%M` | |||||
# Create archive | |||||
for website in `ls ${WEBSITES}`; | |||||
do | |||||
tar czf ${BACKUP_ROOT_WEBSITES}/${website}\_${HOUR}.tar.gz ${WEBSITES}/${website} | |||||
if [ $? -ne 0 ]; then | |||||
echo "ERROR - Archiving website \"${website}\"" | |||||
fi | |||||
done | |||||
# Purge old backup | |||||
echo "Starting websites purge process for backup older than ${BACKUP_WEBSITES_RETENTION} ..." | |||||
find ${BACKUP_ROOT_WEBSITES} -type f -mtime +${BACKUP_WEBSITES_RETENTION} -exec rm -f {} \; |
@@ -0,0 +1,14 @@ | |||||
#!/bin/bash | |||||
# Starting certbot deploy_hook | |||||
echo "Starting certbot deploy_hook ..." | |||||
# Reload nginx | |||||
nginx -t && service nginx reload | |||||
# Reload postfix | |||||
service postfix reload | |||||
# Reload dovecot | |||||
service dovecot reload | |||||
# End deploy_hook | |||||
echo "End certbot deploy_hook process" |
@@ -0,0 +1,18 @@ | |||||
#!/bin/bash | |||||
BACKUP_TARGET=W.X.Y.Z | |||||
BACKUP_PORT=XXX | |||||
BACKUP_MAC=AA:BB:CC:DD:EE:FF | |||||
BACKUP_TARGET_ROOT=/data/allella/ | |||||
TRANSFERT_USER=backupuser | |||||
# First wake up ${BACKUP_TARGET} and wait ... | |||||
wakeonlan -i ${BACKUP_TARGET} ${BACKUP_MAC} | |||||
sleep 180 | |||||
# Then | |||||
echo "Starting to push backup using ${BACKUP_TARGET}:${BACKUP_TARGET_ROOT}" | |||||
rsync -azp -e 'ssh -p ${BACKUP_PORT}' /backup /data ${TRANSFERT_USER}@${BACKUP_TARGET}:${BACKUP_TARGET_ROOT} | |||||
# Stop | |||||
ssh -p ${BACKUP_PORT} ${TRANSFERT_USER}@${BACKUP_TARGET} 'sudo shutdown -h' |