Update functions

This is needed for automated restore via Script to the latest Backup file. So the files latest* always point to the newest Backup.
This commit is contained in:
jayki 2017-11-22 16:33:50 +01:00 committed by GitHub
parent 492ca261ce
commit e2dec9b046
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,16 +41,19 @@ function backup_dir_create () {
function backup_files () { function backup_files () {
echo "creating file backup..." echo "creating file backup..."
tar -czf ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz ${ZAMMAD_DIR} tar -czf ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz ${ZAMMAD_DIR}
ln -sfn ${BACKUP_DIR}/${TIMESTAMP}_zammad_files.tar.gz ${BACKUP_DIR}/latest_zammad_files.tar.gz
} }
function backup_db () { function backup_db () {
if [ "${DB_ADAPTER}" == "mysql2" ]; then if [ "${DB_ADAPTER}" == "mysql2" ]; then
echo "creating mysql backup..." echo "creating mysql backup..."
mysqldump --opt --single-transaction -u${DB_USER} -p${DB_PASS} ${DB_NAME} | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.mysql.gz mysqldump --opt --single-transaction -u${DB_USER} -p${DB_PASS} ${DB_NAME} | gzip > ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.mysql.gz
ln -sfn ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.mysql.gz ${BACKUP_DIR}/latest_zammad_db.mysql.gz
elif [ "${DB_ADAPTER}" == "postgresql" ]; then elif [ "${DB_ADAPTER}" == "postgresql" ]; then
echo "creating postgresql backup..." echo "creating postgresql backup..."
su -c "pg_dump -c ${DB_NAME} | gzip > /tmp/${TIMESTAMP}_zammad_db.psql.gz" postgres su -c "pg_dump -c ${DB_NAME} | gzip > /tmp/${TIMESTAMP}_zammad_db.psql.gz" postgres
mv /tmp/${TIMESTAMP}_zammad_db.psql.gz ${BACKUP_DIR} mv /tmp/${TIMESTAMP}_zammad_db.psql.gz ${BACKUP_DIR}
ln -sfn ${BACKUP_DIR}/${TIMESTAMP}_zammad_db.psql.gz ${BACKUP_DIR}/latest_zammad_db.psql.gz
else else
echo "DB ADAPTER not found. if its sqlite backup is already saved in the filebackup" echo "DB ADAPTER not found. if its sqlite backup is already saved in the filebackup"
fi fi