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