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