#!/bin/bash # Script to backup redmine content management systems # Author: A. Palladino # Date: 09 Feb 2011 redmine_backup_dir=/home/pen/backups/redmine_backups # Dump Databases and zip them #/usr/bin/mysqldump -u -p | gzip > /path/to/backup/db/redmine_`date +%y_%m_%d`.sql.gz pen_db_backup_file=$redmine_backup_dir/pen_redmine_db_backup_`date +%y_%m_%d`.sql.gz /usr/bin/mysqldump -u redmine -predmine redmine | gzip > $pen_db_backup_file nab_db_backup_file=$redmine_backup_dir/nab_redmine_db_backup_`date +%y_%m_%d`.sql.gz /usr/bin/mysqldump -u redmine -predmine nab_redmine | gzip > $nab_db_backup_file npdg_db_backup_file=$redmine_backup_dir/npdg_redmine_db_backup_`date +%y_%m_%d`.sql.gz /usr/bin/mysqldump -u redmine -predmine npdg_redmine | gzip > $npdg_db_backup_file #Let's not fill up the backup directory #Check if there are more than 5 of each? If so, remove the oldest for expt in pen nab npdg do if [ $(ls $redmine_backup_dir/${expt}_redmine_db_backup_*.gz | wc -l) -gt 5 ]; then echo $(ls $redmine_backup_dir/${expt}_redmine_db_backup_*.gz | wc -l) rm -fv `ls -tr $redmine_backup_dir/${expt}_redmine_db_backup_*.gz | head -n 1` fi done # RSYNC Attachments rsync -a /opt/redmine-0.8.7/files $redmine_backup_dir/pen_redmine_attachments_backup rsync -a /opt/redmine-0.8.7_nab/files $redmine_backup_dir/nab_redmine_attachments_backup rsync -a /opt/redmine-0.8.7_npdg/files $redmine_backup_dir/npdg_redmine_attachments_backup exit 0