Redmine backups should include: 红雷备份应包括:
- Database
- 数据库
- Attachments (stored in the
files
directory under the installation directory by default) - 附件(默认情况下存储在安装目录下的 files 目录中)
Backing up database
备份数据库
MySQL
The mysqldump
command can be used to backup the contents of your MySQL database to a text file. For example:
Mysqldump 命令可以用来将 MySQL 数据库的内容备份到一个文本文件中,例如:
/usr/bin/mysqldump -u <username> -p<password> -h <hostname> <redmine_database> > /path/to/backup/db/redmine.sql
/usr/bin/mysqldump-u < 用户名 >-p < 密码 >-h < hostname > < redmine _ database > >/path/to/back/db/redmine.sql
You can find <username>
, <password>
, <hostname>
, and <redmine_database>
in the file config/database.yml
. <host_name>
may not be required depending on your installation of the database.
您可以在 config/database. yml 文件中找到 < username > 、 < password > 、 < hostname > 和 < redmine _ database > 。< host _ name > 可能不是必需的,这取决于数据库的安装情况。
PostgreSQL
The pg_dump
command can be used to backup the contents of a PostgreSQL database to a text file. Here is an example:
Pg _ dump 命令可用于将 PostgreSQL 数据库的内容备份到文本文件。这里有一个例子:
/usr/bin/pg_dump -U <username> -h <hostname> -Fc --file=redmine.sqlc <redmine_database>
/usr/bin/pg _ dump-U < username >-h < hostname >-Fc —— file = redmine.sqlc < redmine _ database >
You can find <username>
, <hostname>
, and <redmine_database>
in the file config/database.yml
. <hostname>
may not be required depending on your installation of the database. The pg_dump
command will prompt you to enter the password when necessary.
您可以在 config/database. yml 文件中找到 < username > 、 < hostname > 和 < redmine _ database > 。< hostname > 可能不是必需的,这取决于数据库的安装情况。Pg _ dump 命令将在必要时提示您输入密码。
SQLite
SQLite databases are all contained in a single file, so you can back them up by copying the file to another location.
SQLite 数据库都包含在一个文件中,因此可以通过将该文件复制到另一个位置来备份它们。
You can determine the file name of SQLite database by looking at config/database.yml
.
您可以通过查看 config/database. yml 来确定 SQLite 数据库的文件名。
Backing up attachments
备份附件
All file uploads are stored in attachments_storage_path
(defaults to the files/
directory). You can copy the contents of this directory to another location to easily back it up.
所有文件上传都存储在 attachments _ Storage _ path (默认为 files/目录)中。您可以将此目录的内容复制到另一个位置,以便轻松备份。
WARNING: attachments_storage_path
may point to a different directory other than files/
. Be sure to check the setting in config/configuration.yml
to avoid making a useless backup.
警告: attachments _ Storage _ path 可能指向文件/以外的其他目录。一定要检查 config/configation.yml 中的设置,以避免产生无用的备份。
Sample backup script
备份脚本示例
Here is a simple shell script that can be used for daily backups (assuming you're using a MySQL database):
下面是一个简单的 shell 脚本,可用于日常备份(假设您使用的是 MySQL 数据库) :
# 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
# Database/usr/bin/mysqldump-u < username >-p < password > < redmine _ Database > | gzip >/path/to/back/db/redmine _‘ date +% Y -% m -% d‘ . gz # Attachments rsync-a/path/to/redmine/files/path/to/back/files
Restore
恢复
Restoring a database
还原数据库
MySQL
For example if you have a gziped dump file with the name 2018-07-30.gz
, then the database can be restored with the following command:
例如,如果您有一个名为2018-07-30.gz 的 gzip 转储文件,那么可以使用以下命令还原数据库:
gunzip -c 2018-07-30.gz | mysql -u <username> --password <redmine_database>
Enter password:
Gunzip-c 2018-07-30.gz | mysql-u < 用户名 > —— password < redmine _ database > 输入密码:
PostgreSQL
When the option -Fc
of the command pg_dump
is used like it is at the above example then you need to use the command pg_restore
:
当命令 pg _ dump 的选项 -Fc 像上面的示例一样被使用时,您需要使用命令 pg _ return:
pg_restore -U <username> -h <hostname> -d <redmine_database> redmine.sqlc
Pg _ return-U < username >-h < hostname >-d < redmine _ database > redmine.sqlc
otherwise a text file can be restored with psql
:
否则,可以使用 psql 恢复文本文件:
psql <redmine_database> < <infile>
Psql < redmine _ database > < < file >
SQLite
Copy the database file from the backup location.
从备份位置复制数据库文件。