RedmineBackupRestore » History » Revision 2
Revision 1 (Go MAEDA, 2018-01-10 15:08) → Revision 2/14 (Go MAEDA, 2018-01-11 01:11)
h1. Backing up and restoring Redmine
{{>toc}}
h2. Backup
Redmine backups should include:
* Database
* Attachments (stored in the @files@ directory of your Redmine install)
h3. Backing up database
h4. MySQL
The @mysqldump@ command can be used to backup the contents of your MySQL database to a text file. For example:
<pre>
/usr/bin/mysqldump -u <username> -p<password> -h<hostname> <redmine_database> > /path/to/backup/db/redmine.sql
</pre>
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.
h4. PostgreSQL
The @pg_dump@ command can be used to backup the contents of a PostgreSQL database to a text file. Here is an example:
<pre>
/usr/bin/pg_dump -U <username> -h <hostname> -Fc --file=redmine.sqlc <redmine_database>
</pre>
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.
h4. SQLite
SQLite databases are all contained in a single file, so you can back them up by copying the file to another location.
You can determine the file name of SQLite database by looking at @config/database.yml@.
h3. Backing up attachments
All file uploads are stored in the @files/@ directory. You can copy the contents of this directory to another location to easily back it up.
h3. Sample backup script
Here is a simple shell script that can be used for daily backups (assuming you're using a MySQL database):
<pre>
# 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
</pre>
h2. Restore
TODO