##// END OF EJS Templates
docs: added restoration commands for DBs
marcink -
r941:eb62cf1f default
parent child Browse files
Show More
@@ -1,127 +1,134 b''
1 .. _backup-ref:
1 .. _backup-ref:
2
2
3 Backup and Restore
3 Backup and Restore
4 ==================
4 ==================
5
5
6 *“The condition of any backup is unknown until a restore is attempted.”*
6 *“The condition of any backup is unknown until a restore is attempted.”*
7 `Schrödinger's Backup`_
7 `Schrödinger's Backup`_
8
8
9 To snapshot an instance of |RCE|, and save its settings, you need to backup the
9 To snapshot an instance of |RCE|, and save its settings, you need to backup the
10 following parts of the system at the same time.
10 following parts of the system at the same time.
11
11
12 * The |repos| managed by the instance.
12 * The |repos| managed by the instance.
13 * The |RCE| database.
13 * The |RCE| database.
14 * Any configuration files or extensions that you've configured.
14 * Any configuration files or extensions that you've configured. In most
15 cases it's only the :file:`rhodecode.ini` file.
15
16
16 .. important::
17 .. important::
17
18
18 Ideally you should script all of these functions so that it creates a
19 Ideally you should script all of these functions so that it creates a
19 backup snapshot of your system at a particular timestamp and then run that
20 backup snapshot of your system at a particular timestamp and then run that
20 script regularly.
21 script regularly.
21
22
22 Backup Details
23 Backup Details
23 --------------
24 --------------
24
25
25 To backup the relevant parts of |RCE| required to restore your system, use
26 To backup the relevant parts of |RCE| required to restore your system, use
26 the information in this section to identify what is important to you.
27 the information in this section to identify what is important to you.
27
28
28 Repository Backup
29 Repository Backup
29 ^^^^^^^^^^^^^^^^^
30 ^^^^^^^^^^^^^^^^^
30
31
31 To back up your |repos|, use the API to get a list of all |repos| managed,
32 To back up your |repos|, use the API to get a list of all |repos| managed,
32 and then clone them to your backup location.
33 and then clone them to your backup location.
33
34
34 Use the ``get_repos`` method to list all your managed |repos|,
35 Use the ``get_repos`` method to list all your managed |repos|,
35 and use the ``clone_uri`` information that is returned. See the :ref:`api`
36 and use the ``clone_uri`` information that is returned. See the :ref:`api`
36 for more information.
37 for more information.
37
38
38 .. important::
39 .. important::
39
40
40 This will not work for |svn| |repos|. Currently the only way to back up
41 This will not work for |svn| |repos|. Currently the only way to back up
41 your |svn| |repos| is to make a copy of them.
42 your |svn| |repos| is to make a copy of them.
42
43
43 It is also important to note, that you can only restore the |svn| |repos|
44 It is also important to note, that you can only restore the |svn| |repos|
44 using the same version as they were saved with.
45 using the same version as they were saved with.
45
46
46 Database Backup
47 Database Backup
47 ^^^^^^^^^^^^^^^
48 ^^^^^^^^^^^^^^^
48
49
49 The instance database contains all the |RCE| permissions settings,
50 The instance database contains all the |RCE| permissions settings,
50 and user management information. To backup your database,
51 and user management information. To backup your database,
51 export it using the following appropriate example, and then move it to your
52 export it using the following appropriate example, and then move it to your
52 backup location:
53 backup location:
53
54
54 .. code-block:: bash
55 .. code-block:: bash
55
56
56 # For MySQL DBs
57 # For MySQL DBs
57 $ mysqldump -u <uname> -p <pass> db_name > mysql-db-backup
58 $ mysqldump -u <uname> -p <pass> rhodecode_db_name > mysql-db-backup
59 # MySQL restore command
60 $ mysql -u <uname> -p <pass> rhodecode_db_name < mysql-db-backup
58
61
59 # For PostgreSQL DBs
62 # For PostgreSQL DBs
60 $ pg_dump dbname > postgresql-db-backup
63 $ PGPASSWORD=<pass> pg_dump rhodecode_db_name > postgresql-db-backup
64 # PosgreSQL restore
65 $ PGPASSWORD=<pass> psql -U <uname> -h localhost -d rhodecode_db_name -1 -f postgresql-db-backup
61
66
62 # For SQLlite
67 # For SQLite
63 $ sqlite3 rhodecode.db ‘.dump’ > sqlite-db-backup
68 $ sqlite3 rhodecode.db ‘.dump’ > sqlite-db-backup
69 # SQLite restore
70 $ copy sqlite-db-backup rhodecode.db
64
71
65
72
66 The default |RCE| SQLite database location is
73 The default |RCE| SQLite database location is
67 :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.db`
74 :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.db`
68
75
69 If running MySQL or PostgreSQL databases, you will have configured these
76 If running MySQL or PostgreSQL databases, you will have configured these
70 separately, for more information see :ref:`rhodecode-database-ref`
77 separately, for more information see :ref:`rhodecode-database-ref`
71
78
72 Configuration File Backup
79 Configuration File Backup
73 ^^^^^^^^^^^^^^^^^^^^^^^^^
80 ^^^^^^^^^^^^^^^^^^^^^^^^^
74
81
75 Depending on your setup, you could have a number of configuration files that
82 Depending on your setup, you could have a number of configuration files that
76 should be backed up. You may have some, or all of the configuration files
83 should be backed up. You may have some, or all of the configuration files
77 listed in the :ref:`config-rce-files` section. Ideally you should back these
84 listed in the :ref:`config-rce-files` section. Ideally you should back these
78 up at the same time as the database and |repos|.
85 up at the same time as the database and |repos|.
79
86
80 Gist Backup
87 Gist Backup
81 ^^^^^^^^^^^
88 ^^^^^^^^^^^
82
89
83 To backup the gists on your |RCE| instance you can use the ``get_users`` and
90 To backup the gists on your |RCE| instance you can use the ``get_users`` and
84 ``get_gists`` API methods to fetch the gists for each user on the instance.
91 ``get_gists`` API methods to fetch the gists for each user on the instance.
85
92
86 Extension Backups
93 Extension Backups
87 ^^^^^^^^^^^^^^^^^
94 ^^^^^^^^^^^^^^^^^
88
95
89 You should also backup any extensions added in the
96 You should also backup any extensions added in the
90 :file:`home/{user}/.rccontrol/{instance-id}/rcextensions` directory.
97 :file:`home/{user}/.rccontrol/{instance-id}/rcextensions` directory.
91
98
92 Full-text Search Backup
99 Full-text Search Backup
93 ^^^^^^^^^^^^^^^^^^^^^^^
100 ^^^^^^^^^^^^^^^^^^^^^^^
94
101
95 You may also have full text search set up, but the index can be rebuild from
102 You may also have full text search set up, but the index can be rebuild from
96 re-imported |repos| if necessary. You will most likely want to backup your
103 re-imported |repos| if necessary. You will most likely want to backup your
97 :file:`mapping.ini` file if you've configured that. For more information, see
104 :file:`mapping.ini` file if you've configured that. For more information, see
98 the :ref:`indexing-ref` section.
105 the :ref:`indexing-ref` section.
99
106
100 Restoration Steps
107 Restoration Steps
101 -----------------
108 -----------------
102
109
103 To restore an instance of |RCE| from its backed up components, use the
110 To restore an instance of |RCE| from its backed up components, use the
104 following steps.
111 following steps.
105
112
106 1. Install a new instance of |RCE|.
113 1. Install a new instance of |RCE|.
107 2. Once installed, configure the instance to use the backed up
114 2. Once installed, configure the instance to use the backed up
108 :file:`rhodecode.ini` file. Ensure this file points to the backed up
115 :file:`rhodecode.ini` file. Ensure this file points to the backed up
109 database, see the :ref:`config-database` section.
116 database, see the :ref:`config-database` section.
110 3. Restart |RCE| and remap and rescan your |repos|, see the
117 3. Restart |RCE| and remap and rescan your |repos|, see the
111 :ref:`remap-rescan` section.
118 :ref:`remap-rescan` section.
112
119
113 Post Restoration Steps
120 Post Restoration Steps
114 ^^^^^^^^^^^^^^^^^^^^^^
121 ^^^^^^^^^^^^^^^^^^^^^^
115
122
116 Once you have restored your |RCE| instance to basic functionality, you can
123 Once you have restored your |RCE| instance to basic functionality, you can
117 then work on restoring any specific setup changes you had made.
124 then work on restoring any specific setup changes you had made.
118
125
119 * To recreate the |RCE| index, use the backed up :file:`mapping.ini` file if
126 * To recreate the |RCE| index, use the backed up :file:`mapping.ini` file if
120 you had made changes and rerun the indexer. See the
127 you had made changes and rerun the indexer. See the
121 :ref:`indexing-ref` section for details.
128 :ref:`indexing-ref` section for details.
122 * To reconfigure any extensions, copy the backed up extensions into the
129 * To reconfigure any extensions, copy the backed up extensions into the
123 :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions` and also specify
130 :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions` and also specify
124 any custom hooks if necessary. See the :ref:`extensions-hooks-ref` section for
131 any custom hooks if necessary. See the :ref:`extensions-hooks-ref` section for
125 details.
132 details.
126
133
127 .. _Schrödinger's Backup: http://novabackup.novastor.com/blog/schrodingers-backup-good-bad-backup/
134 .. _Schrödinger's Backup: http://novabackup.novastor.com/blog/schrodingers-backup-good-bad-backup/
General Comments 0
You need to be logged in to leave comments. Login now