author | Julien Cristau <julien.cristau@logilab.fr> |
Fri, 17 Jul 2015 13:49:58 +0200 | |
changeset 10542 | 53a2b00b6758 |
parent 10491 | c67bcee93248 |
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 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
4 |
Backups (mostly with postgresql) |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
5 |
-------------------------------- |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
6 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
7 |
It is always a good idea to backup. If your system does not do that, |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
8 |
you should set it up. Note that whenever you do an upgrade, |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
9 |
`cubicweb-ctl` offers you to backup your database. There are a number |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
10 |
of ways for doing backups. |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
11 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
12 |
Using postgresql (and only that) |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
13 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
14 |
|
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
15 |
Before you |
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
16 |
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
|
17 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
18 |
# 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
|
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 |
# 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
|
21 |
# 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
|
22 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
23 |
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
|
24 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
25 |
# 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
|
26 |
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
|
27 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
28 |
Using :command:`cubicweb-ctl db-dump` |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
29 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
30 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
31 |
The CubicWeb way is to use the :command:`db-dump` command. For that, |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
32 |
you have to put your passwords in a user-only-readable file at the |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
33 |
home directory of root user. The file is `.pgpass` (`chmod 0600`), in |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
34 |
this case for a socket run connection to PostgreSQL :: |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
35 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
36 |
/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
|
37 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
38 |
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
|
39 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
40 |
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
|
41 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
42 |
# 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
|
43 |
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
|
44 |
|
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
45 |
|
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
46 |
Backup ninja |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
47 |
~~~~~~~~~~~~ |
4429
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
48 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
49 |
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
|
50 |
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
|
51 |
|
5002
0ce27e435b3a
[D] book: update backup procedures in additional tips
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
4784
diff
changeset
|
52 |
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
|
53 |
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
|
54 |
|
0cd207567f37
le patch admin_tips_for_backup a été importé
Sylvain Thénault <sylvain.thenault@logilab.fr>
parents:
diff
changeset
|
55 |
.. _`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
|
56 |
.. _`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
|
57 |
.. _`backuppc` : http://backuppc.sourceforge.net/ |
5400
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
58 |
|
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
59 |
.. warning:: |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
60 |
|
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
61 |
Remember that these indications will fail you whenever you use |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
62 |
another database backend than postgres. Also it does properly handle |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
63 |
externally managed data such as files (using the Bytes File System |
b7ab099b128a
[doc/book] various content fixes
Aurelien Campeas <aurelien.campeas@logilab.fr>
parents:
5002
diff
changeset
|
64 |
Storage). |