Created
April 9, 2014 09:24
-
-
Save JosefJezek/10246523 to your computer and use it in GitHub Desktop.
Backup script for GLPI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Backup script for GLPI | |
GLPI_DIR='/usr/share/glpi'; | |
BACKUP_DIR='/root/backup'; | |
LOGFILE='/var/log/glpi/backup.log'; | |
DBUSER=root | |
DBPASS= | |
DATE=`date +%d.%m.%Y`; | |
LOGTIME=`date +"%d-%m-%Y %H:%m"`; | |
DBCONFIG=`find $GLPI_DIR -name "config_db.php"`; | |
DBNAME=`grep "dbdefault" $DBCONFIG | cut -d "'" -f 2`; | |
GLPISIZE=`du -sh $GLPI_DIR`; | |
echo -e "$LOGTIME \t## New backup started ##" >> $LOGFILE; | |
echo -e "$LOGTIME \tCreating mysqldump into $BACKUP_DIR/sqldump.$DATE.sql ..." >> $LOGFILE; | |
mysqldump -u $DBUSER -p$DBPASS $DBNAME > $BACKUP_DIR/sqldump.$DATE.sql; | |
echo -e "$LOGTIME \tpacking: $GLPISIZE.. into $BACKUP_DIR/backup.$DATE.tar.bz2 ..." >> $LOGFILE; | |
tar -cjPf $BACKUP_DIR/backup.$DATE.tar.bz2 $GLPI_DIR $BACKUP_DIR/sqldump.$DATE.sql >> $LOGFILE; | |
rm -f sqldump*.sql | |
# Go back to original working directory. | |
echo -e "$LOGTIME \tAll done..." >> $LOGFILE; | |
echo "all done! "; | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment