author | Aurelien Campeas <aurelien.campeas@logilab.fr> |
Thu, 08 Apr 2010 17:50:37 +0200 | |
branch | stable |
changeset 5189 | 84d4587a92bc |
parent 5002 | 0ce27e435b3a |
child 5400 | b7ab099b128a |
permissions | -rw-r--r-- |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
1 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
2 |
.. _Additional Tips: |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
3 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
4 |
Additional Tips |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
5 |
--------------- |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
7 |
Here are some additional tips as far as administration of a CubicWeb is concerned. |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
8 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
9 |
Backup, backup, backup |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
10 |
`````````````````````` |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
12 |
It is always a good idea to backup. If your system does not do that, you should |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
13 |
set it up. Note that whenever you do an upgrade, `cubicweb-ctl` offers you to |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
14 |
backup your database. There are a number of ways for doing backups. Before you |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
15 |
go ahead, make sure the following permissions are correct :: |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
16 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
# chgrp postgres /var/lib/cubicweb/backup |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
19 |
# chmod g+ws /var/lib/cubicweb/backup |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
20 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
# chgrp postgres /etc/cubicweb.d/*<instance>*/sources |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
22 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
# chmod g+r /etc/cubicweb.d/*<instance>*/sources |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
24 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
25 |
**Classic way on PostgreSQL server** |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
26 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
27 |
Simply use the pg_dump in a cron installed for `postgres` user on the database server:: |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
29 |
# m h dom mon dow command |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
30 |
0 2 * * * pg_dump -Fc --username=cubicweb --no-owner <instance> > /var/backups/<instance>-$(date '+%Y-%m-%d_%H:%M:%S').dump |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
31 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
32 |
**CubicWeb way** |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
34 |
The CubicWeb way is to use the `db-dump` command. For that, you have to put |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
35 |
your passwords in a user-only-readable file at the home directory of root user. |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
36 |
The file is `.pgpass` (`chmod 0600`), in this case for a socket run connection |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
37 |
to PostgreSQL :: |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
39 |
/var/run/postgresql:5432:<instance>:<database user>:<database password> |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
40 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
41 |
The postgres documentation for the `.pgpass` format can be found `here`_ |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
43 |
Then add the following command to the crontab of the user (`crontab -e`):: |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
44 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
45 |
# m h dom mon dow command |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
46 |
0 2 * * * cubicweb-ctl db-dump <instance> |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
**The automated sysadmin way** |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
50 |
You can use a combination `backup-ninja`_ (which has a postgres script in the |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
51 |
example directory), `backuppc`)_ (for versionning). |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
53 |
Please note that in the *CubicWeb way* it adds a second location for your |
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
54 |
password which is error-prone. |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
55 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
56 |
.. _`here` : http://www.postgresql.org/docs/current/static/libpq-pgpass.html |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
57 |
.. _`backup-ninja` : https://labs.riseup.net/code/projects/show/backupninja/ |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
58 |
.. _`backuppc` : http://backuppc.sourceforge.net/ |