Show More
@@ -1,134 +1,151 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 together with the stored Gists. | |
13 | * The |RCE| database. |
|
13 | * The |RCE| database. | |
14 | * Any configuration files or extensions that you've configured. In most |
|
14 | * Any configuration files or extensions that you've configured. In most | |
15 | cases it's only the :file:`rhodecode.ini` file. |
|
15 | cases it's only the :file:`rhodecode.ini` file. | |
|
16 | * Installer files such as those in `/opt/rhodecode` can be backed-up, however | |||
|
17 | it's not required since in case of a recovery installer simply | |||
|
18 | re-creates those. | |||
|
19 | ||||
16 |
|
20 | |||
17 | .. important:: |
|
21 | .. important:: | |
18 |
|
22 | |||
19 | Ideally you should script all of these functions so that it creates a |
|
23 | Ideally you should script all of these functions so that it creates a | |
20 | backup snapshot of your system at a particular timestamp and then run that |
|
24 | backup snapshot of your system at a particular timestamp and then run that | |
21 | script regularly. |
|
25 | script regularly. | |
22 |
|
26 | |||
23 | Backup Details |
|
27 | Backup Details | |
24 | -------------- |
|
28 | -------------- | |
25 |
|
29 | |||
26 | To backup the relevant parts of |RCE| required to restore your system, use |
|
30 | To backup the relevant parts of |RCE| required to restore your system, use | |
27 | the information in this section to identify what is important to you. |
|
31 | the information in this section to identify what is important to you. | |
28 |
|
32 | |||
29 | Repository Backup |
|
33 | Repository Backup | |
30 | ^^^^^^^^^^^^^^^^^ |
|
34 | ^^^^^^^^^^^^^^^^^ | |
31 |
|
35 | |||
32 | To back up your |repos|, use the API to get a list of all |repos| managed, |
|
36 | To back up your |repos|, use the API to get a list of all |repos| managed, | |
33 | and then clone them to your backup location. |
|
37 | and then clone them to your backup location. This is the most safe backup option. | |
|
38 | Backing up the storage directory could potentially result in a backup of | |||
|
39 | partially committed files or commits. (Backup taking place during a big push) | |||
|
40 | As an alternative you could use a rsync or simple `cp` commands if you can | |||
|
41 | ensure your instance is only in read-only mode or stopped at the moment. | |||
|
42 | ||||
34 |
|
43 | |||
35 | Use the ``get_repos`` method to list all your managed |repos|, |
|
44 | Use the ``get_repos`` method to list all your managed |repos|, | |
36 | and use the ``clone_uri`` information that is returned. See the :ref:`api` |
|
45 | and use the ``clone_uri`` information that is returned. See the :ref:`api` | |
37 | for more information. |
|
46 | for more information. Be sure to keep the structure or repositories with their | |
|
47 | repository groups. | |||
38 |
|
48 | |||
39 | .. important:: |
|
49 | .. important:: | |
40 |
|
50 | |||
41 | This will not work for |svn| |repos|. Currently the only way to back up |
|
51 | This will not work for |svn| |repos|. Currently the only way to back up | |
42 | your |svn| |repos| is to make a copy of them. |
|
52 | your |svn| |repos| is to make a copy of them. | |
43 |
|
53 | |||
44 | It is also important to note, that you can only restore the |svn| |repos| |
|
54 | It is also important to note, that you can only restore the |svn| |repos| | |
45 | using the same version as they were saved with. |
|
55 | using the same version as they were saved with. | |
46 |
|
56 | |||
47 | Database Backup |
|
57 | Database Backup | |
48 | ^^^^^^^^^^^^^^^ |
|
58 | ^^^^^^^^^^^^^^^ | |
49 |
|
59 | |||
50 | The instance database contains all the |RCE| permissions settings, |
|
60 | The instance database contains all the |RCE| permissions settings, | |
51 | and user management information. To backup your database, |
|
61 | and user management information. To backup your database, | |
52 | export it using the following appropriate example, and then move it to your |
|
62 | export it using the following appropriate example, and then move it to your | |
53 | backup location: |
|
63 | backup location: | |
54 |
|
64 | |||
55 | .. code-block:: bash |
|
65 | .. code-block:: bash | |
56 |
|
66 | |||
57 | # For MySQL DBs |
|
67 | # For MySQL DBs | |
58 | $ mysqldump -u <uname> -p <pass> rhodecode_db_name > mysql-db-backup |
|
68 | $ mysqldump -u <uname> -p <pass> rhodecode_db_name > mysql-db-backup | |
59 | # MySQL restore command |
|
69 | # MySQL restore command | |
60 | $ mysql -u <uname> -p <pass> rhodecode_db_name < mysql-db-backup |
|
70 | $ mysql -u <uname> -p <pass> rhodecode_db_name < mysql-db-backup | |
61 |
|
71 | |||
62 | # For PostgreSQL DBs |
|
72 | # For PostgreSQL DBs | |
63 | $ PGPASSWORD=<pass> pg_dump rhodecode_db_name > postgresql-db-backup |
|
73 | $ PGPASSWORD=<pass> pg_dump rhodecode_db_name > postgresql-db-backup | |
64 | # PosgreSQL restore |
|
74 | # PosgreSQL restore | |
65 | $ PGPASSWORD=<pass> psql -U <uname> -h localhost -d rhodecode_db_name -1 -f postgresql-db-backup |
|
75 | $ PGPASSWORD=<pass> psql -U <uname> -h localhost -d rhodecode_db_name -1 -f postgresql-db-backup | |
66 |
|
76 | |||
67 | # For SQLite |
|
77 | # For SQLite | |
68 | $ sqlite3 rhodecode.db ‘.dump’ > sqlite-db-backup |
|
78 | $ sqlite3 rhodecode.db ‘.dump’ > sqlite-db-backup | |
69 | # SQLite restore |
|
79 | # SQLite restore | |
70 | $ copy sqlite-db-backup rhodecode.db |
|
80 | $ copy sqlite-db-backup rhodecode.db | |
71 |
|
81 | |||
72 |
|
82 | |||
73 | The default |RCE| SQLite database location is |
|
83 | The default |RCE| SQLite database location is | |
74 | :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.db` |
|
84 | :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.db` | |
75 |
|
85 | |||
76 | If running MySQL or PostgreSQL databases, you will have configured these |
|
86 | If running MySQL or PostgreSQL databases, you will have configured these | |
77 | separately, for more information see :ref:`rhodecode-database-ref` |
|
87 | separately, for more information see :ref:`rhodecode-database-ref` | |
78 |
|
88 | |||
79 | Configuration File Backup |
|
89 | Configuration File Backup | |
80 | ^^^^^^^^^^^^^^^^^^^^^^^^^ |
|
90 | ^^^^^^^^^^^^^^^^^^^^^^^^^ | |
81 |
|
91 | |||
82 | Depending on your setup, you could have a number of configuration files that |
|
92 | Depending on your setup, you could have a number of configuration files that | |
83 | should be backed up. You may have some, or all of the configuration files |
|
93 | should be backed up. You may have some, or all of the configuration files | |
84 | listed in the :ref:`config-rce-files` section. Ideally you should back these |
|
94 | listed in the :ref:`config-rce-files` section. Ideally you should back these | |
85 | up at the same time as the database and |repos|. |
|
95 | up at the same time as the database and |repos|. It really depends on if you need | |
|
96 | the configuration file like logs, custom modules. We always recommend backing | |||
|
97 | those up. | |||
86 |
|
98 | |||
87 | Gist Backup |
|
99 | Gist Backup | |
88 | ^^^^^^^^^^^ |
|
100 | ^^^^^^^^^^^ | |
89 |
|
101 | |||
90 |
To backup the gists on your |RCE| instance you |
|
102 | To backup the gists on your |RCE| instance you usually have to backup the | |
91 | ``get_gists`` API methods to fetch the gists for each user on the instance. |
|
103 | gist storage path. If this haven't been changed it's located inside | |
|
104 | :file:`.rc_gist_store` and the metadata in :file:`.rc_gist_metadata`. | |||
|
105 | You can use the ``get_users`` and ``get_gists`` API methods to fetch the | |||
|
106 | gists for each user on the instance. | |||
92 |
|
107 | |||
93 | Extension Backups |
|
108 | Extension Backups | |
94 | ^^^^^^^^^^^^^^^^^ |
|
109 | ^^^^^^^^^^^^^^^^^ | |
95 |
|
110 | |||
96 | You should also backup any extensions added in the |
|
111 | You should also backup any extensions added in the | |
97 | :file:`home/{user}/.rccontrol/{instance-id}/rcextensions` directory. |
|
112 | :file:`home/{user}/.rccontrol/{instance-id}/rcextensions` directory. | |
98 |
|
113 | |||
99 | Full-text Search Backup |
|
114 | Full-text Search Backup | |
100 | ^^^^^^^^^^^^^^^^^^^^^^^ |
|
115 | ^^^^^^^^^^^^^^^^^^^^^^^ | |
101 |
|
116 | |||
102 | You may also have full text search set up, but the index can be rebuild from |
|
117 | You may also have full text search set up, but the index can be rebuild from | |
103 | re-imported |repos| if necessary. You will most likely want to backup your |
|
118 | re-imported |repos| if necessary. You will most likely want to backup your | |
104 | :file:`mapping.ini` file if you've configured that. For more information, see |
|
119 | :file:`mapping.ini` file if you've configured that. For more information, see | |
105 | the :ref:`indexing-ref` section. |
|
120 | the :ref:`indexing-ref` section. | |
106 |
|
121 | |||
107 | Restoration Steps |
|
122 | Restoration Steps | |
108 | ----------------- |
|
123 | ----------------- | |
109 |
|
124 | |||
110 |
To restore an instance of |RCE| from its backed up components, |
|
125 | To restore an instance of |RCE| from its backed up components, to a fresh | |
111 | following steps. |
|
126 | system use the following steps. | |
112 |
|
127 | |||
113 | 1. Install a new instance of |RCE|. |
|
128 | 1. Install a new instance of |RCE| using sqlite option as database. | |
114 | 2. Once installed, configure the instance to use the backed up |
|
129 | 2. Restore your database. | |
115 | :file:`rhodecode.ini` file. Ensure this file points to the backed up |
|
130 | 2. Once installed, replace you backed up the :file:`rhodecode.ini` with your | |
|
131 | backup version. Ensure this file points to the restored | |||
116 | database, see the :ref:`config-database` section. |
|
132 | database, see the :ref:`config-database` section. | |
117 |
3. Restart |RCE| and remap and rescan your |repos| |
|
133 | 3. Restart |RCE| and remap and rescan your |repos| to verify filesystem access, | |
118 | :ref:`remap-rescan` section. |
|
134 | see the :ref:`remap-rescan` section. | |
|
135 | ||||
119 |
|
136 | |||
120 | Post Restoration Steps |
|
137 | Post Restoration Steps | |
121 | ^^^^^^^^^^^^^^^^^^^^^^ |
|
138 | ^^^^^^^^^^^^^^^^^^^^^^ | |
122 |
|
139 | |||
123 | Once you have restored your |RCE| instance to basic functionality, you can |
|
140 | Once you have restored your |RCE| instance to basic functionality, you can | |
124 | then work on restoring any specific setup changes you had made. |
|
141 | then work on restoring any specific setup changes you had made. | |
125 |
|
142 | |||
126 | * To recreate the |RCE| index, use the backed up :file:`mapping.ini` file if |
|
143 | * To recreate the |RCE| index, use the backed up :file:`mapping.ini` file if | |
127 | you had made changes and rerun the indexer. See the |
|
144 | you had made changes and rerun the indexer. See the | |
128 | :ref:`indexing-ref` section for details. |
|
145 | :ref:`indexing-ref` section for details. | |
129 | * To reconfigure any extensions, copy the backed up extensions into the |
|
146 | * To reconfigure any extensions, copy the backed up extensions into the | |
130 | :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions` and also specify |
|
147 | :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions` and also specify | |
131 | any custom hooks if necessary. See the :ref:`extensions-hooks-ref` section for |
|
148 | any custom hooks if necessary. See the :ref:`extensions-hooks-ref` section for | |
132 | details. |
|
149 | details. | |
133 |
|
150 | |||
134 | .. _Schrödinger's Backup: http://novabackup.novastor.com/blog/schrodingers-backup-good-bad-backup/ |
|
151 | .. _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