author | Julien Jehannet <julien.jehannet@logilab.fr> |
Fri, 26 Feb 2010 17:00:42 +0100 | |
branch | stable |
changeset 4784 | eed95a456b88 |
parent 4429 | 0cd207567f37 |
child 5002 | 0ce27e435b3a |
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 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
12 |
It is always a good idea to backup. If your system does not do that, |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
13 |
you should set it up. Note that whenever you do an upgrade, |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
14 |
`cubicweb-ctl` offers you to backup your database. |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
15 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
16 |
There are a number of ways for doing backups. Before you go ahead, |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
17 |
make sure the following permissions are correct :: |
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 |
# 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
|
20 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
21 |
# 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
|
22 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
23 |
# 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
|
24 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
25 |
# 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
|
26 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
27 |
**Classic way** |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
28 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
29 |
Simply use the pg_dump in a cron :: |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
|
4784
eed95a456b88
le patch documentation-admin-tips a été importé
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4429
diff
changeset
|
31 |
su -c "pg_dump -Fc --username=cubicweb --no-owner" postgres > <your-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
|
32 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
33 |
**CubicWeb way** |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
34 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
The CubicWeb way is to use the `db-dump` command. For that, you have to put your passwords in a user-only-readable file at the |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
36 |
root of the postgres user. The file is `.pgpass` (`chmod 0600`), in this case for a socket run connection to postgres :: |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
37 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
/var/run/postgresql:5432:<instance>:cubicweb:<password> |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
39 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
40 |
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
|
41 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
Then add the following command to the crontab of the postgres user (`su posgres 'crontab -e'`):: |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
43 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
44 |
# 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
|
45 |
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
|
46 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
47 |
**The automated sysadmin way** |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
49 |
You can use a combination `backup-ninja`_ (which has a postgres script in the example directory), `backuppc`)_ (for versionning). |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
50 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
51 |
Please note that in the *CubicWeb way* it adds a second location for your password which is error-prone. |
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
52 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
53 |
.. _`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
|
54 |
.. _`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
|
55 |
.. _`backuppc` : http://backuppc.sourceforge.net/ |