Skip to content
Snippets Groups Projects
Unverified Commit 31456a7b authored by Pavel Vyskočil's avatar Pavel Vyskočil
Browse files

Added script for db backup

parent a513a263
No related branches found
No related tags found
No related merge requests found
...@@ -8,4 +8,7 @@ All nagios scripts are located under `nagios` directory. ...@@ -8,4 +8,7 @@ All nagios scripts are located under `nagios` directory.
* Script for remove all logs from test accounts from SimpleSAMLlogs * Script for remove all logs from test accounts from SimpleSAMLlogs
* Params: * Params:
* 1 - The file name * 1 - The file name
\ No newline at end of file
### backup_database.sh
* Do mysqldump into `/opt/mariadb_backup` and remove all dump file older than 7 days
\ No newline at end of file
#!/bin/bash
BACKUP_FOLDER="/opt/mariadb_backup"
# Ensure that backup folder exist
if [[ ! -d ${BACKUP_FOLDER} ]]; then
mkdir ${BACKUP_FOLDER}
fi
BACKUP_FILE_NAME=${BACKUP_FOLDER}/backup_$(date -u +'%Y-%m-%d_%HH:%MM').sql
# Backup all databases
mysqldump --all-databases > ${BACKUP_FILE_NAME}
echo "Database was dumped into ${BACKUP_FILE_NAME}"
#Remove old backups > 7days
find ${BACKUP_FOLDER} -name "backup_*.sql" -type f -mtime +7 -delete
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment