7 Here are some additional tips as far as administration of a CubicWeb is concerned. |
7 Here are some additional tips as far as administration of a CubicWeb is concerned. |
8 |
8 |
9 Backup, backup, backup |
9 Backup, backup, backup |
10 `````````````````````` |
10 `````````````````````` |
11 |
11 |
12 It is always a good idea to backup. If your system does not do that, |
12 It is always a good idea to backup. If your system does not do that, you should |
13 you should set it up. Note that whenever you do an upgrade, |
13 set it up. Note that whenever you do an upgrade, `cubicweb-ctl` offers you to |
14 `cubicweb-ctl` offers you to backup your database. |
14 backup your database. There are a number of ways for doing backups. Before you |
15 |
15 go ahead, make sure the following permissions are correct :: |
16 There are a number of ways for doing backups. Before you go ahead, |
|
17 make sure the following permissions are correct :: |
|
18 |
16 |
19 # chgrp postgres /var/lib/cubicweb/backup |
17 # chgrp postgres /var/lib/cubicweb/backup |
20 |
18 |
21 # chmod g+ws /var/lib/cubicweb/backup |
19 # chmod g+ws /var/lib/cubicweb/backup |
22 |
20 |
23 # chgrp postgres /etc/cubicweb.d/*<instance>*/sources |
21 # chgrp postgres /etc/cubicweb.d/*<instance>*/sources |
24 |
22 |
25 # chmod g+r /etc/cubicweb.d/*<instance>*/sources |
23 # chmod g+r /etc/cubicweb.d/*<instance>*/sources |
26 |
24 |
27 **Classic way** |
25 **Classic way on PostgreSQL server** |
28 |
26 |
29 Simply use the pg_dump in a cron :: |
27 Simply use the pg_dump in a cron installed for `postgres` user on the database server:: |
30 |
28 |
31 su -c "pg_dump -Fc --username=cubicweb --no-owner" postgres > <your-instance>-$(date '+%Y-%m-%d_%H:%M:%S').dump |
29 # m h dom mon dow command |
|
30 0 2 * * * pg_dump -Fc --username=cubicweb --no-owner <instance> > /var/backups/<instance>-$(date '+%Y-%m-%d_%H:%M:%S').dump |
32 |
31 |
33 **CubicWeb way** |
32 **CubicWeb way** |
34 |
33 |
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 |
34 The CubicWeb way is to use the `db-dump` command. For that, you have to put |
36 root of the postgres user. The file is `.pgpass` (`chmod 0600`), in this case for a socket run connection to postgres :: |
35 your passwords in a user-only-readable file at the home directory of root user. |
|
36 The file is `.pgpass` (`chmod 0600`), in this case for a socket run connection |
|
37 to PostgreSQL :: |
37 |
38 |
38 /var/run/postgresql:5432:<instance>:cubicweb:<password> |
39 /var/run/postgresql:5432:<instance>:<database user>:<database password> |
39 |
40 |
40 The postgres documentation for the `.pgpass` format can be found `here`_ |
41 The postgres documentation for the `.pgpass` format can be found `here`_ |
41 |
42 |
42 Then add the following command to the crontab of the postgres user (`su posgres 'crontab -e'`):: |
43 Then add the following command to the crontab of the user (`crontab -e`):: |
43 |
44 |
44 # m h dom mon dow command |
45 # m h dom mon dow command |
45 0 2 * * * cubicweb-ctl db-dump <instance> |
46 0 2 * * * cubicweb-ctl db-dump <instance> |
46 |
47 |
47 **The automated sysadmin way** |
48 **The automated sysadmin way** |
48 |
49 |
49 You can use a combination `backup-ninja`_ (which has a postgres script in the example directory), `backuppc`)_ (for versionning). |
50 You can use a combination `backup-ninja`_ (which has a postgres script in the |
|
51 example directory), `backuppc`)_ (for versionning). |
50 |
52 |
51 Please note that in the *CubicWeb way* it adds a second location for your password which is error-prone. |
53 Please note that in the *CubicWeb way* it adds a second location for your |
|
54 password which is error-prone. |
52 |
55 |
53 .. _`here` : http://www.postgresql.org/docs/current/static/libpq-pgpass.html |
56 .. _`here` : http://www.postgresql.org/docs/current/static/libpq-pgpass.html |
54 .. _`backup-ninja` : https://labs.riseup.net/code/projects/show/backupninja/ |
57 .. _`backup-ninja` : https://labs.riseup.net/code/projects/show/backupninja/ |
55 .. _`backuppc` : http://backuppc.sourceforge.net/ |
58 .. _`backuppc` : http://backuppc.sourceforge.net/ |