How to backup Redmine on Google Storage

If you would like to backup your Redmine database and files, you might to consider Google Storage as your backup location. It comes with a 100 GB free monthly usage.

First, you need to sign up for a Google Storage account if you don’t have an account already.

Once done, download and install GSUtil which is a command line tool, allowing you to manage buckets.

Paste the following script into a file called “”

# required settings 
REDMINE_ROOT='' # e.g. /home/peter/rails/'
BACKUP_ROOT='' # e.g. /home/peter/backups (will be created)

# optional settings
GS_FILENAME='backup_'`date +%Y%m%d`'.tar.gz'

echo 'Setting up directories'
mkdir $BACKUP_ROOT/redmine/db -p
mkdir $BACKUP_ROOT/redmine/files -p

echo 'Backing up database'
/usr/bin/mysqldump -u $DB_USERNAME --password=$DB_PASSWORD $DB_NAME | gzip > $BACKUP_ROOT/redmine/db/`date +%Y%m%d`.gz

echo 'Backing up attachments'
rsync -a $REDMINE_ROOT/files/ $BACKUP_ROOT/redmine/files/

echo 'Packing into single archive'
tar -czPf $GS_FILENAME $BACKUP_ROOT/redmine/

echo 'Creating bucket on Google Storage (if not already created)'
gsutil mb $GS_ROOT

echo 'Copying backup archive to Google Storage'

echo 'Cleanup by removing archive'

echo 'Backup complete'

You might want to apply execute rights to your script using

chmod +x

And maybe even add it to your crontab to get daily backups

crontab -e

Then add this line

@daily FULL_PATH_TO_SCRIPT > /dev/null

That’s it.

Let me know if you improve this script.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.