Index: openacs-4/packages/acs-core-docs/www/backup-recovery.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/backup-recovery.html,v diff -u -r1.15.2.2 -r1.15.2.3 --- openacs-4/packages/acs-core-docs/www/backup-recovery.html 21 Nov 2003 11:14:06 -0000 1.15.2.2 +++ openacs-4/packages/acs-core-docs/www/backup-recovery.html 3 Dec 2003 21:16:26 -0000 1.15.2.3 @@ -1,8 +1,8 @@ -Backup and Recovery

Backup and Recovery

By Don Baccus with additions - by Joel Aufrecht

+Backup and Recovery

Backup and Recovery

By Don Baccus with additions + by Joel Aufrecht


OpenACS docs are written by the named authors, and may be edited by OpenACS documentation staff. -

Backup Strategy

+

Backup Strategy

The purpose of backup is to enable recovery. Backup and recovery are always risky; here are some steps that minimize the chance recovery is necessary: @@ -36,7 +36,7 @@ /var/lib/aolserver/service0/database-backup, then you can apply standard file-based backup strategies to /var/lib/aolserver/service0 -

Snapshot backup and recovery

This section describes how to make a one-time backup and +

Manual backup and recovery

This section describes how to make a one-time backup and restore of the files and database. This is useful for rolling back to known-good versions of a service, such as at initial installation and just before an upgrade. First, you back up the @@ -106,7 +106,7 @@ . exporting dimensions . exporting post-schema procedural objects and actions . exporting statistics - Export terminated successfully without warnings.

  • PostGreSQL.�Create a backup file and verify that it was created and has a reasonable size (several megabytes).

    [root@localhost root]# su - service0
    +              Export terminated successfully without warnings.
  • PostgreSQL.�Create a backup file and verify that it was created and has a reasonable size (several megabytes).

    [root@localhost root]# su - service0
                 [service0@localhost service0]$ pg_dump -f /var/lib/aolserver/service0/database-backup/before_upgrade_to_4.6.dmp service0
                 [service0@localhost service0]$ ls -al /var/lib/aolserver/service0/database-backup/before_upgrade_to_4.6.dmp 
                 -rw-rw-r-x    1 service0  service0   4005995 Feb 21 18:28 /var/lib/aolserver/service0/database-backup/before_upgrade_to_4.6.dmp
    @@ -173,75 +173,9 @@
                     
  • Activate the service

    [root@yourserver root]# ln -s /var/lib/aolserver/service0/etc/daemontools /service/service0
                 [root@yourserver root]# sleep 10
                 [root@yourserver root]# svgroup web /service/service0
    -            [root@yourserver root]#
  • Automated Backup (OPTIONAL)

    Backup can encompass all files in - /var/lib/aolserver/service0. Use one cron job to back up the database to a file in - /var/lib/aolserver/service0/database-backup, and a second cron job to back up the entire file tree.

    Postgres automatic backup

    Backing up the database consists of creating a file - which is a picture of the database at a particular moment. - Postgres can be backed up while running.

    Depending on your overall backup strategy, you can - create a series of database backup files (recommended for a development server where you are using the section called “Using CVS for backup-recovery”), or you can create a - single nightly backup file which is then collected into a - bigger backup file that includes the other parts of the - service. The latter technique is more generally recommended. To make a new file every - night, edit the crontab file for service0:

    [service0@yourserver service0]$ export EDITOR=emacs;crontab -e

    Add this line to the file. The numbers and stars at the beginning are cron columns that specify when the program should be run - in this case, whenever the minute is 0 and the hour is 1, i.e., 1:00 am every day.

    0 1 * * * /usr/local/pgsql/bin/pg_dump -f /var/lib/aolserver/service0/database-backup/service0_`date +\%Y-\%m-\%d`.dmp service0

    If you plan to back up the whole /var/lib/aolserver/service0 directory, then it would be redundant to keep a history of database backups. In that case, set up the cron job to overwrite the previous backup each time:

    0 1 * * * /usr/local/pgsql/bin/pg_dump -f /var/lib/aolserver/service0/database-backup/service0_nightly.dmp service0

    A full Backup/Recovery cycle

    On a test service, make sure that your backup-recovery process work. After backing up the database and file system, delete the service as detailed below and then recover it.

    Other Backup Strategies

    Earlier strategies, included here because this section - hasn't been fully updated yet.

    Set Up Nightly Oracle Exports

    Edit the backup script to save the backup - file in /var/lib/aolserver/service0/database-backup. - While you're working with Oracle, you should configure it to do - automatic exports. An export is a separate backup copy of the - database. This copy includes all of the database's state at the - time that the export was initiated. If your database is corrupted, - you can restore from one of these backups. You should do this step as - root. -

    - Automating backups is accomplished using the UNIX - crontab facility.

    - While still root, run the - following command. You can replace the - EDITOR="emacs -nw" - portion with whatever editor your prefer, such as - EDITOR=vi. -

    -        root:~# export EDITOR="emacs -nw"
    -      root:~# crontab -e

    Now add the following line on a line by itself

    -      0 23 * * * /usr/sbin/export-oracle

    - Save the file, exit the editor. Verify that the addition - succeeded by checking the output of the following command.

    -        root:~# crontab -l | grep export-oracle
    -        0 23 * * * /usr/sbin/export-oracle
    -        root:~# exit
    -      ; Logout

    If you see the line, go ahead and log out.

    Set up nightly Postgres exports

    This is an alternate method to the crontabls - backup. - Dowload this script - to /tmp. At the top of the script - are several variables that you'll need to customize: -

    • - bak - location where you want - local backups to be saved -

    • - servername - name of your server - (and database instance) -

    • - ftp_user - username on your ftp - account -

    • - ftp_password - password on your - ftp account -

    • - ftp_dir - path on the remote - server where your backups will be uploaded -

    • - ftp_server - your ftp server -

    - - Next, we'll save this file to our server's - tcl directory so that it will be - loaded on startup. It will automatically be run every night at - midnight. Note that this script only backs up the database - not the - OpenACS scripts and file content. -

    -        joeuser:~$ cp /tmp/acs-pgbackup-init.txt ~/var/lib/aolserver/birdnotes/tcl/acs-pgbackup-init.tcl
    -      joeuser:~$ restart-aolserver birdnotes

    - That's it! The script will email you with each successful backup (or - if it fails, it will send you an email with the reason) -

    Using CVS for backup-recovery

    If you are already using CVS, you probably don't + [root@yourserver root]#

    Automated Backup (OPTIONAL)

    The recommended backup strategy for a production sit is to use an automated script which first backs up the database to a file in /var/lib/aolserver/service0/database-backup and then backs up all of /var/lib/aolserver/service0 to a single zip file, and then copies that zip file to another computer.

    1. Make sure that the manual backup process described above works.

    2. Customize the default backup script. Edit /var/lib/aolserver/service0/etc/backup.sh with your specific parameters.

    3. + Make sure the file is executable:

      chmod +x backup.sh
    4. + Set this file to run automatically by adding a line to root's crontab. (Typically, with export EDITOR=emacs; crontab -e.) This example runs the backup script at 1:30 am every day.

      30 1 * * * *        sh /var/lib/aolserver/service0/etc/backup.sh

    Using CVS for backup-recovery

    CVS-only backup is often appropriate for development sites. If you are already using CVS and your data is not important, you probably don't need to do anything to back up your files. Just make sure that your current work is checked into the system. You can then roll back based on date - note the