RedmineBackupRestore » History » Version 8
Gerd Pokorra, 2018-07-31 18:41
Add a sentence to the SQLite retore topic
1 | 1 | Go MAEDA | h1. Backing up and restoring Redmine |
---|---|---|---|
2 | 1 | Go MAEDA | |
3 | 1 | Go MAEDA | {{>toc}} |
4 | 1 | Go MAEDA | |
5 | 1 | Go MAEDA | h2. Backup |
6 | 1 | Go MAEDA | |
7 | 1 | Go MAEDA | Redmine backups should include: |
8 | 1 | Go MAEDA | * Database |
9 | 4 | Go MAEDA | * Attachments (stored in the @files@ directory under the installation directory by default) |
10 | 1 | Go MAEDA | |
11 | 1 | Go MAEDA | h3. Backing up database |
12 | 1 | Go MAEDA | |
13 | 1 | Go MAEDA | h4. MySQL |
14 | 1 | Go MAEDA | |
15 | 1 | Go MAEDA | The @mysqldump@ command can be used to backup the contents of your MySQL database to a text file. For example: |
16 | 1 | Go MAEDA | <pre> |
17 | 4 | Go MAEDA | /usr/bin/mysqldump -u <username> -p<password> -h <hostname> <redmine_database> > /path/to/backup/db/redmine.sql |
18 | 1 | Go MAEDA | </pre> |
19 | 1 | Go MAEDA | |
20 | 2 | Go MAEDA | 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. |
21 | 2 | Go MAEDA | |
22 | 1 | Go MAEDA | h4. PostgreSQL |
23 | 1 | Go MAEDA | |
24 | 1 | Go MAEDA | The @pg_dump@ command can be used to backup the contents of a PostgreSQL database to a text file. Here is an example: |
25 | 1 | Go MAEDA | <pre> |
26 | 2 | Go MAEDA | /usr/bin/pg_dump -U <username> -h <hostname> -Fc --file=redmine.sqlc <redmine_database> |
27 | 1 | Go MAEDA | </pre> |
28 | 1 | Go MAEDA | |
29 | 2 | Go MAEDA | 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. |
30 | 2 | Go MAEDA | |
31 | 1 | Go MAEDA | h4. SQLite |
32 | 1 | Go MAEDA | |
33 | 1 | Go MAEDA | SQLite databases are all contained in a single file, so you can back them up by copying the file to another location. |
34 | 2 | Go MAEDA | |
35 | 2 | Go MAEDA | You can determine the file name of SQLite database by looking at @config/database.yml@. |
36 | 1 | Go MAEDA | |
37 | 1 | Go MAEDA | h3. Backing up attachments |
38 | 1 | Go MAEDA | |
39 | 3 | Go MAEDA | 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. |
40 | 3 | Go MAEDA | |
41 | 3 | Go MAEDA | 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. |
42 | 1 | Go MAEDA | |
43 | 1 | Go MAEDA | h3. Sample backup script |
44 | 1 | Go MAEDA | |
45 | 1 | Go MAEDA | Here is a simple shell script that can be used for daily backups (assuming you're using a MySQL database): |
46 | 1 | Go MAEDA | |
47 | 1 | Go MAEDA | <pre> |
48 | 1 | Go MAEDA | # Database |
49 | 1 | Go MAEDA | /usr/bin/mysqldump -u <username> -p<password> <redmine_database> | gzip > /path/to/backup/db/redmine_`date +%Y-%m-%d`.gz |
50 | 1 | Go MAEDA | |
51 | 1 | Go MAEDA | # Attachments |
52 | 1 | Go MAEDA | rsync -a /path/to/redmine/files /path/to/backup/files |
53 | 1 | Go MAEDA | </pre> |
54 | 1 | Go MAEDA | |
55 | 1 | Go MAEDA | h2. Restore |
56 | 1 | Go MAEDA | |
57 | 5 | Gerd Pokorra | h3. Restoring a database |
58 | 5 | Gerd Pokorra | |
59 | 5 | Gerd Pokorra | h4. MySQL |
60 | 5 | Gerd Pokorra | |
61 | 6 | Gerd Pokorra | 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: |
62 | 5 | Gerd Pokorra | |
63 | 5 | Gerd Pokorra | <pre> |
64 | 5 | Gerd Pokorra | gunzip -c 2018-07-30.gz | mysql -u <username> --password <redmine_database> |
65 | 5 | Gerd Pokorra | Enter password: |
66 | 5 | Gerd Pokorra | </pre> |
67 | 5 | Gerd Pokorra | |
68 | 5 | Gerd Pokorra | h4. PostgreSQL |
69 | 5 | Gerd Pokorra | |
70 | 7 | Gerd Pokorra | 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@: |
71 | 7 | Gerd Pokorra | |
72 | 7 | Gerd Pokorra | <pre> |
73 | 7 | Gerd Pokorra | pg_restore -U <username> -h <hostname> -d <redmine_database> redmine.sqlc |
74 | 7 | Gerd Pokorra | </pre> |
75 | 7 | Gerd Pokorra | |
76 | 7 | Gerd Pokorra | otherwise a text file can be restored with @psql@: |
77 | 7 | Gerd Pokorra | |
78 | 7 | Gerd Pokorra | <pre> |
79 | 7 | Gerd Pokorra | psql <redmine_database> < <infile> |
80 | 7 | Gerd Pokorra | </pre> |
81 | 5 | Gerd Pokorra | |
82 | 5 | Gerd Pokorra | h4. SQLite |
83 | 5 | Gerd Pokorra | |
84 | 8 | Gerd Pokorra | Copy the database file from the backup location. |
85 | 5 | Gerd Pokorra | |
86 | 5 | Gerd Pokorra | h3. Restoring attachments |
87 | 5 | Gerd Pokorra | |
88 | 1 | Go MAEDA | TODO |