Forked from gabrielkfr/script-bash-redmine-backups
Last active
September 17, 2021 06:32
-
-
Save ronanguilloux/6497272 to your computer and use it in GitHub Desktop.
Backup script (daily & monthly) for Redmine (full instance + db sql snapshot)
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_redmine.sh | |
# modified by [email protected] | |
# Inspiration: https://gist.github.com/gabrielkfr/6432185 | |
# | |
# Distributed under terms of the MIT license. | |
# -- VARS | |
DAY=`date +"%Y%m%d"` | |
HOUR=`date +"%H%M"` | |
BACKUP_PATH=/var/backups/redmine | |
REDMINE_HOME=/projects/project/www | |
REDMINE_DB_NAME=project | |
REDMINE_DB_USER=project | |
REDMINE_DB_PASS=Password | |
REDMINE_DB_BACKUP=$REDMINE_HOME/backups/redmine_mysql_db.sql | |
REDMINE_BACKUP_NAME="redmine_"$DAY"_"$HOUR".tar.bz2" | |
REDMINE_BACKUP_HISTO="histo_redmine_"$DAY"_"$HOUR".tar.bz2" | |
REDMINE_BACKUP_LIVE_TIME=30 | |
REDMINE_BACKUP_HISTO_LIVE_TIME=365 | |
MODEL_BKP_DAILY=redmine_*.tar.bz2 | |
MODEL_BKP_HISTO=histo_redmine_*.tar.bz2 | |
# -- MySQL | |
echo "Snapshot backuping Redmine's MySQL db into Redmine instance..." | |
mysqldump --user=$REDMINE_DB_USER --password=$REDMINE_DB_PASS $REDMINE_DB_NAME > $REDMINE_DB_BACKUP | |
echo "($REDMINE_DB_BACKUP) done." | |
echo | |
# -- Daily full Redmine dir backup | |
echo "Daily backuping Redmine's directory before sending it to a remote place..." | |
tar -cjf $BACKUP_PATH/$REDMINE_BACKUP_NAME $REDMINE_HOME | |
echo "($BACKUP_PATH/$REDMINE_BACKUP_NAME) done." | |
# -- Monthly full Redmine dir backup | |
TOMORROW=`date --date=tomorrow +%d` | |
if [ $TOMORROW -eq "1" ]; then | |
echo | |
echo "End of month : monthly backuping Redmine's directory..." | |
cp $BACKUP_PATH/$REDMINE_BACKUP_NAME $BACKUP_PATH/$REDMINE_BACKUP_HISTO | |
echo "($BACKUP_PATH/$REDMINE_BACKUP_HISTO) done." | |
fi | |
# -- Purging old outdated backups | |
echo | |
echo "Purging outdated backups..." | |
find $BACKUP_PATH/$MODEL_BKP_DAILY -mtime +$REDMINE_BACKUP_LIVE_TIME -exec rm {} \; | |
find $BACKUP_PATH/$MODEL_BKP_HISTO -mtime +$REDMINE_BACKUP_HISTO_LIVE_TIME -exec rm {} \; | |
echo "done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
New version : https://gist.github.com/ZerooCool/b06925403f94960e32c3c52f2db81b01
Add encrypt aes to 7z
Add a second local backup folder.
Export to DropBox.