Created
February 16, 2009 17:34
-
-
Save rogerleite/65262 to your computer and use it in GitHub Desktop.
Exemplo de script que faz backup do Redmine
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
#ARQUIVO: bkp_redmine.sh | |
#!/bin/sh | |
BACKUP_FOLDER=/home/minha_empresa/backup/redmine | |
DATE_BACKUP=`date +%Y%m%d` | |
DB_FILE_BKP="$BACKUP_FOLDER"/"$DATE_BACKUP"_redmine_db.gz | |
FILES_FOLDER_BKP="$BACKUP_FOLDER"/files | |
FILES_FILE_BKP="$BACKUP_FOLDER"/"$DATE_BACKUP"_redmine_files.gz | |
# Database | |
echo Dumping redmine database to "$DB_FILE_BKP" | |
/usr/bin/mysqldump -u root -p123456 redmine | gzip > "$DB_FILE_BKP" | |
echo Dumping done! | |
# Attachments | |
echo Synchronizing redmine attachments to "$FILES_FOLDER_BKP" | |
rsync -a -v /home/minha_empresa/opt/redmine/files "$FILES_FOLDER_BKP" | |
echo ================================== | |
echo Synchronizing of attachments done! | |
echo | |
echo Zipping "$FILES_FOLDER_BKP" to "$FILES_FILE_BKP" | |
tar -cvzf "$FILES_FILE_BKP" "$FILES_FOLDER_BKP" > /dev/null | |
echo Zip done! | |
# TODO: colocar o destino do SCP em variaveis | |
echo | |
echo Copying backup to rleite@192.168.10.180:/home/rleite/backups_redmine/ | |
scp -P4500 "$DB_FILE_BKP" rleite@192.168.10.180:/home/rleite/backups_redmine/ | |
scp -P4500 "$FILES_FILE_BKP" rleite@192.168.10.180:/home/rleite/backups_redmine/ | |
echo Copying done! | |
#FIM ARQUIVO: bkp_redmine.sh | |
#ARQUIVO: email_and_bkp_redmine.sh | |
#!/bin/sh | |
DATE_BACKUP=`date +%Y%m%d` | |
cd /home/minha_empresa/opt/ | |
echo Iniciando backup ... | |
./bkp_redmine.sh > temp_log_backup.log | |
echo Backup done! | |
echo Enviando e-mail ... | |
cat temp_log_backup.log | mutt -s "Redmine Backup $DATE_BACKUP" rleite@minha_empresa.com.br | |
echo E-mail done! | |
rm temp_log_backup.log | |
cd "$OLDPWD" | |
#FIM ARQUIVO: email_and_bkp_redmine.sh | |
#ARQUIVO: .muttrc | |
set sendmail="/usr/bin/msmtp" | |
set envelope_from=yes | |
set from="redmine@minha_empresa.com.br" | |
#FIM ARQUIVO: .muttrc | |
#ARQUIVO: .msmtprc | |
account default | |
host 200.185.160.30 | |
user redmine | |
password redmine!@# | |
#FIM ARQUIVO: .msmtprc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment