##// END OF EJS Templates
docs: update backup/restore for postgres....
marcink -
r2468:5fbc20e3 default
parent child Browse files
Show More
@@ -1,151 +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 together with the stored Gists.
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
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
17 it's not required since in case of a recovery installer simply
18 re-creates those.
18 re-creates those.
19
19
20
20
21 .. important::
21 .. important::
22
22
23 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
24 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
25 script regularly.
25 script regularly.
26
26
27 Backup Details
27 Backup Details
28 --------------
28 --------------
29
29
30 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
31 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.
32
32
33 Repository Backup
33 Repository Backup
34 ^^^^^^^^^^^^^^^^^
34 ^^^^^^^^^^^^^^^^^
35
35
36 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,
37 and then clone them to your backup location. This is the most safe backup option.
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
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)
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
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.
41 ensure your instance is only in read-only mode or stopped at the moment.
42
42
43
43
44 Use the ``get_repos`` method to list all your managed |repos|,
44 Use the ``get_repos`` method to list all your managed |repos|,
45 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`
46 for more information. Be sure to keep the structure or repositories with their
46 for more information. Be sure to keep the structure or repositories with their
47 repository groups.
47 repository groups.
48
48
49 .. important::
49 .. important::
50
50
51 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
52 your |svn| |repos| is to make a copy of them.
52 your |svn| |repos| is to make a copy of them.
53
53
54 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|
55 using the same version as they were saved with.
55 using the same version as they were saved with.
56
56
57 Database Backup
57 Database Backup
58 ^^^^^^^^^^^^^^^
58 ^^^^^^^^^^^^^^^
59
59
60 The instance database contains all the |RCE| permissions settings,
60 The instance database contains all the |RCE| permissions settings,
61 and user management information. To backup your database,
61 and user management information. To backup your database,
62 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
63 backup location:
63 backup location:
64
64
65 .. code-block:: bash
65 .. code-block:: bash
66
66
67 # For MySQL DBs
67 # For MySQL DBs
68 $ mysqldump -u <uname> -p <pass> rhodecode_db_name > mysql-db-backup
68 $ mysqldump -u <uname> -p <pass> rhodecode_db_name > mysql-db-backup
69 # MySQL restore command
69 # MySQL restore command
70 $ mysql -u <uname> -p <pass> rhodecode_db_name < mysql-db-backup
70 $ mysql -u <uname> -p <pass> rhodecode_db_name < mysql-db-backup
71
71
72 # For PostgreSQL DBs
72 # For PostgreSQL DBs
73 $ PGPASSWORD=<pass> pg_dump rhodecode_db_name > postgresql-db-backup
73 $ PGPASSWORD=<pass> pg_dump --inserts -U <uname> -h localhost rhodecode_db_name > postgresql-db-backup
74 # PosgreSQL restore
74 # PosgreSQL restore
75 $ 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
76
76
77 # For SQLite
77 # For SQLite
78 $ sqlite3 rhodecode.db ‘.dump’ > sqlite-db-backup
78 $ sqlite3 rhodecode.db ‘.dump’ > sqlite-db-backup
79 # SQLite restore
79 # SQLite restore
80 $ copy sqlite-db-backup rhodecode.db
80 $ copy sqlite-db-backup rhodecode.db
81
81
82
82
83 The default |RCE| SQLite database location is
83 The default |RCE| SQLite database location is
84 :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.db`
84 :file:`/home/{user}/.rccontrol/{instance-id}/rhodecode.db`
85
85
86 If running MySQL or PostgreSQL databases, you will have configured these
86 If running MySQL or PostgreSQL databases, you will have configured these
87 separately, for more information see :ref:`rhodecode-database-ref`
87 separately, for more information see :ref:`rhodecode-database-ref`
88
88
89 Configuration File Backup
89 Configuration File Backup
90 ^^^^^^^^^^^^^^^^^^^^^^^^^
90 ^^^^^^^^^^^^^^^^^^^^^^^^^
91
91
92 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
93 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
94 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
95 up at the same time as the database and |repos|. It really depends on if you need
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
96 the configuration file like logs, custom modules. We always recommend backing
97 those up.
97 those up.
98
98
99 Gist Backup
99 Gist Backup
100 ^^^^^^^^^^^
100 ^^^^^^^^^^^
101
101
102 To backup the gists on your |RCE| instance you usually have to backup the
102 To backup the gists on your |RCE| instance you usually have to backup the
103 gist storage path. If this haven't been changed it's located inside
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`.
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
105 You can use the ``get_users`` and ``get_gists`` API methods to fetch the
106 gists for each user on the instance.
106 gists for each user on the instance.
107
107
108 Extension Backups
108 Extension Backups
109 ^^^^^^^^^^^^^^^^^
109 ^^^^^^^^^^^^^^^^^
110
110
111 You should also backup any extensions added in the
111 You should also backup any extensions added in the
112 :file:`home/{user}/.rccontrol/{instance-id}/rcextensions` directory.
112 :file:`home/{user}/.rccontrol/{instance-id}/rcextensions` directory.
113
113
114 Full-text Search Backup
114 Full-text Search Backup
115 ^^^^^^^^^^^^^^^^^^^^^^^
115 ^^^^^^^^^^^^^^^^^^^^^^^
116
116
117 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
118 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
119 :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
120 the :ref:`indexing-ref` section.
120 the :ref:`indexing-ref` section.
121
121
122 Restoration Steps
122 Restoration Steps
123 -----------------
123 -----------------
124
124
125 To restore an instance of |RCE| from its backed up components, to a fresh
125 To restore an instance of |RCE| from its backed up components, to a fresh
126 system use the following steps.
126 system use the following steps.
127
127
128 1. Install a new instance of |RCE| using sqlite option as database.
128 1. Install a new instance of |RCE| using sqlite option as database.
129 2. Restore your database.
129 2. Restore your database.
130 3. Once installed, replace you backed up the :file:`rhodecode.ini` with your
130 3. Once installed, replace you backed up the :file:`rhodecode.ini` with your
131 backup version. Ensure this file points to the restored
131 backup version. Ensure this file points to the restored
132 database, see the :ref:`config-database` section.
132 database, see the :ref:`config-database` section.
133 4. Restart |RCE| and remap and rescan your |repos| to verify filesystem access,
133 4. Restart |RCE| and remap and rescan your |repos| to verify filesystem access,
134 see the :ref:`remap-rescan` section.
134 see the :ref:`remap-rescan` section.
135
135
136
136
137 Post Restoration Steps
137 Post Restoration Steps
138 ^^^^^^^^^^^^^^^^^^^^^^
138 ^^^^^^^^^^^^^^^^^^^^^^
139
139
140 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
141 then work on restoring any specific setup changes you had made.
141 then work on restoring any specific setup changes you had made.
142
142
143 * 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
144 you had made changes and rerun the indexer. See the
144 you had made changes and rerun the indexer. See the
145 :ref:`indexing-ref` section for details.
145 :ref:`indexing-ref` section for details.
146 * To reconfigure any extensions, copy the backed up extensions into the
146 * To reconfigure any extensions, copy the backed up extensions into the
147 :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions` and also specify
147 :file:`/home/{user}/.rccontrol/{instance-id}/rcextensions` and also specify
148 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
149 details.
149 details.
150
150
151 .. _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