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