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