Project

General

Profile

RE: How to backup redmine? ยป backup_redmine.sh

Mindaugas Kairys, 2013-09-13 23:04

 
1
#!/bin/bash
2

    
3
# !ensure that this file cannot be read by others, only by root,
4
# as it contains redmine database credentials!
5

    
6
DATE=`date +"%Y%m%d"`
7
BACKUP_DIR=/var/backup/redmine
8
DB_USER="redmine"
9
DB_PASS="your_password"
10
REDMINE_HOME=/var/redmine
11
DB_CHARSET=utf8
12

    
13
# delete old backups
14
find $BACKUP_DIR -maxdepth 1 -type d -mtime +62 -exec rm -rf {} \;
15

    
16
# create backup dir
17
mkdir -p $BACKUP_DIR/$DATE
18

    
19
# backup db
20
mysqldump -u $DB_USER -p${DB_PASS} --single-transaction --default-character-set=${DB_CHARSET} redmine | gzip > $BACKUP_DIR/${DATE}/mysql.gz
21

    
22
# backup redmine
23
tar -pzcf $BACKUP_DIR/${DATE}/redmine.tar.gz -C $REDMINE_HOME .
    (1-1/1)