如何在Redmine中备份和恢复数据库

10/22/2023
4 minutes
卢卡什·贝尼

Redmine是一个免费的项目管理工具,使用Ruby on Rails编写。这个开源的Web应用程序是用于问题跟踪和时间管理的最佳项目管理工具之一。以下是一些在Redmine中备份和恢复数据库的方法。

Whether you consider Redmine as an issue tracker or a project management tool, these web application features are amazing. Many professionals trust this application because Redmine is fully customizable, and you can set user roles and responsibilities for different employees.

This means only employees or teams working on the project can see the details and progress. You can also build a support system as it allows you to create as many forums as possible in one project. Furthermore, anyone can view the threads and forums. Your customers and clients can also include a wiki link or revision code through the issue tracker.

The best part about open-source applications such as Redmine is that you can also add third-party plugins and increase the application's features. For instance, you can also send invoices and estimates to your clients and customers.

All these benefits of Remine highlight how essential this web application can be for your business and facilitate streamlining tasks and processes. Businesses also use this software for document management and customer support.

Now let's get back to the principal question – how to backup and restore the database in Redmine?


1. Backing up the Database


MySQL

You can use the mysqldump command and backup your MySQL database content in a text file. For instance:

/usr/bin/mysqldump -u <username> -p<password> -h <hostname><redmine_database>> /path/to/backup/db/redmine.sql

Visit config/database.yml to find the username, password, Redmine database, and hostname. The hostname is not necessarily needed.


PostgreSQL

If you want to export or backup PostgreSQL database, you can use the command pg_dump. This will export the data into a text file. For instance:

/usr/bin/pg_dump -U <username> -h <hostname> -Fc --file=redmine.sqlc<redmine_database>

Visit config/database.yml to find the username, password, Redmine database, and hostname. The hostname is not necessarily needed. When necessary, you need to enter the password in the pg_dump command.


SQLite

You can easily back up the SQLite databases by copying the same file to another location, which only includes a single file.

Look at config/database.yml and determine the name of the file.


2. Backing up the Attachments

Every file that is attached to the software is stored in a default location files/directory. You can simply visit the location and copy the content and paste the file where you want for the backup.


Sample Backup Script

For daily backups you can use this simple shell script for MySQL database:

# Database

/usr/bin/mysqldump -u <username> -p<password><redmine_database> | gzip> /path/to/backup/db/redmine_`date +%Y-%m-%d`.gz

# Attachments

rsync -a /path/to/redmine/files /path/to/backup/files


3. Restoring the Database


MySQL

For instance, if you have a file that is named as 2020-07-30.gz, then you can restore the database by using the following command:

gunzip -c 2020-07-30.gz | mysql -u <username> --password <redmine_database>

Enter password.


PostgreSQL

You have to use pq_restore command when –Fc option is used in the pg_dump command as an above example:

pg_restore -U <username> -h <hostname> -d <redmine_database>redmine.sqlc

You can also restore the text file through psql command:

psql<redmine_database><<infile>


SQLite

You can copy your database file stored in the location.


Conclusion

Redmine is a complete solution that you need for project management and issue tracking. However, there are various ways in which you can use this application. The features that Redmine offers are user-friendly, and as this application is free, you can save a lot of expense by choosing this software.

You can boost your productivity and save a lot of time by making the right decision and choosing Redmine for your business projects.

终极Redmine升级?轻松搞定。

在一个软件中获得完美的项目规划、管理和控制的强大工具。

尝试Easy Redmine 30天免费试用

完整功能,SSL 保护,每日备份,在您的地理位置