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.1.2.7 -r1.1.2.8 --- openacs-4/packages/acs-core-docs/www/backup-recovery.html 4 May 2003 06:30:02 -0000 1.1.2.7 +++ openacs-4/packages/acs-core-docs/www/backup-recovery.html 7 May 2003 17:40:58 -0000 1.1.2.8 @@ -1,10 +1,10 @@ -Backup and Recovery

Backup and Recovery

+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: @@ -33,74 +33,74 @@ OpenACS installations comprise files and database contents. If you follow the reference install and put all files, including configuration files, in - /web/servicename/, + /web/servicename/, and back up the database nightly to a file in - /web/servicename/database-backup, + /web/servicename/database-backup, then you can apply standard file-based backup strategies to the root directory. -

Set up Nightly Postgres Exports

A quick way to automate database backup is a cron job. +

Set up Nightly Postgres Exports

A quick way to automate database backup is a cron job. (This should moved into OpenACS's scheduled task project so that - it's integrated with OpenACS's alerts and such.)

[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 /web/service0/database-backup/service0_$(date +%Y-%m-%d).dmp service0

Back up the file system

Here's a quick manual way to back up a reference install - + it's integrated with OpenACS's alerts and such.)

[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 /web/service0/database-backup/service0_$(date +%Y-%m-%d).dmp service0

Back up the file system

Here's a quick manual way to back up a reference install - it should be replaced by an automated script within OpenACS. The command excludes the auto-generated - supervise directory, which is - unneccesary and has complicated permissions. Make sure that you are using the cron job to back up the database to a file in /web/service0/database-backup so that the tar command will include the database.

[root@yourserver root]# su - service0
-[service0@yourserver service0]$ tar -cpsj --exclude /web/service0/etc/daemontools/supervise --file /tmp/service0-backup.tar.bz2 /web/service0/ 
+      supervise directory, which is
+      unneccesary and has complicated permissions.  Make sure that you are using the cron job to back up the database to a file in /web/service0/database-backup so that the tar command will include the database.

[root@yourserver root]# su - service0
+[service0@yourserver service0]$ tar -cpsj --exclude /web/service0/etc/daemontools/supervise --file /tmp/service0-backup.tar.bz2 /web/service0/ 
 tar: Removing leading `/' from member names
-[service0@yourserver service0]$

Testing

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.

[root@yourserver root]# svc -d /service/service0
-[root@yourserver root]# mv /web/service0/ /web/service0.lost
-[root@yourserver root]# rm /service/service0
+[service0@yourserver service0]$

Testing

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.

[root@yourserver root]# svc -d /service/service0
+[root@yourserver root]# mv /web/service0/ /web/service0.lost
+[root@yourserver root]# rm /service/service0
 rm: remove symbolic link `/service/service0'? y
-[root@yourserver root]# ps -auxw | grep service0
+[root@yourserver root]# ps -auxw | grep service0
 root      1496  0.0  0.0  1312  252 ?        S    16:58   0:00 supervise service0
-[root@yourserver root]# kill 1496
-[root@yourserver root]# ps -auxw | grep service0
-[root@yourserver root]# su - postgres
-[postgres@yourserver pgsql]$ dropdb service0
+[root@yourserver root]# kill 1496
+[root@yourserver root]# ps -auxw | grep service0
+[root@yourserver root]# su - postgres
+[postgres@yourserver pgsql]$ dropdb service0
 DROP DATABASE
-[postgres@yourserver pgsql]$ dropuser service0
+[postgres@yourserver pgsql]$ dropuser service0
 DROP USER
-[postgres@yourserver pgsql]$ exit
+[postgres@yourserver pgsql]$ exit
 logout
-[root@yourserver root]#

Recovery

  1. Restore the operating system and required software. +[root@yourserver root]#

Recovery

  1. Restore the operating system and required software. You can do this with standard backup processes or by keeping copies of the install material (OS CDs, OpenACS - tarball and supporting software) and repeating the install guide.

  2. Restore the OpenACS service. Assuming the user already exists, restore the database and files from backup and restore the daemontools link. (Because of a bug in Postgres backup-recovery, not all database objects are created in the correct order. To compensate, pre-creating some objects usually work.)

    [root@yourserver root]# su - postgres
    -[postgres@yourserver pgsql]$ createuser service0
    -Shall the new user be allowed to create databases? (y/n) y
    -Shall the new user be allowed to create more new users? (y/n) y
    +          tarball and supporting software) and repeating the install guide.

  3. Restore the OpenACS service. Assuming the user already exists, restore the database and files from backup and restore the daemontools link. (Because of a bug in Postgres backup-recovery, not all database objects are created in the correct order. To compensate, pre-creating some objects usually work.)

    [root@yourserver root]# su - postgres
    +[postgres@yourserver pgsql]$ createuser service0
    +Shall the new user be allowed to create databases? (y/n) y
    +Shall the new user be allowed to create more new users? (y/n) y
     CREATE USER
    -[postgres@yourserver pgsql]$ exit
    +[postgres@yourserver pgsql]$ exit
     logout
     
    -[root@yourserver root]# su - service0
    -[service0@yourserver service0]$ cd /web
    -[service0@yourserver web]$ tar xjf /tmp/service0-backup.tar.bz2
    -[service0@yourserver web]$ chmod -R 700 service0
    -[service0@yourserver web]$ createdb service0
    +[root@yourserver root]# su - service0
    +[service0@yourserver service0]$ cd /web
    +[service0@yourserver web]$ tar xjf /tmp/service0-backup.tar.bz2
    +[service0@yourserver web]$ chmod -R 700 service0
    +[service0@yourserver web]$ createdb service0
     CREATE DATABASE
    -[service0@yourserver web]$ psql -f /web/service0/packages/acs-kernel/sql/postgresql/postgresql.sql service0
    +[service0@yourserver web]$ psql -f /web/service0/packages/acs-kernel/sql/postgresql/postgresql.sql service0
     (many lines omitted)
    -[service0@yourserver web]$ psql service0 < /web/service0/database-backup/database-backup.dmp
    +[service0@yourserver web]$ psql service0 < /web/service0/database-backup/database-backup.dmp
     (many lines omitted)
    -[service0@yourserver web]$ exit
    -[root@yourserver root]# ln -s /web/service0/etc/daemontools /service/service0
    -[root@yourserver root]# sleep 10
    -[root@yourserver root]# svgroup web /service/service0
    -[root@yourserver root]#

Other Backup Strategies

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

Set Up Nightly Oracle Exports

+[service0@yourserver web]$ exit +[root@yourserver root]# ln -s /web/service0/etc/daemontools /service/service0 +[root@yourserver root]# sleep 10 +[root@yourserver root]# svgroup web /service/service0 +[root@yourserver root]#

Other Backup Strategies

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

Set Up Nightly Oracle Exports

(This has not yet been updated to fit with the Reference install. To do so, edit the backup script to save the backup - file in /web/servicename/database-backup). + file in /web/servicename/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. + root.

  • Download the backup script. Save the file export-oracle.txt as - /tmp/export-oracle.txt + /tmp/export-oracle.txt

  • Login as root. The following commands will install the export script:

    @@ -110,18 +110,18 @@
     root:~# chmod 700 /usr/sbin/export-oracle
  • Setup the export directory; this is the directory where backups will be stored. We recommend the directory - /ora8/m02/oracle-exports.

    +        /ora8/m02/oracle-exports.

     root:~# mkdir /ora8/m02/oracle-exports
     root:~# chown oracle.dba /ora8/m02/oracle-exports
     root:~# chmod 770 /ora8/m02/oracle-exports
  • Now edit - /usr/sbin/export-oracle and - change the SERVICE_NAME and - DATABASE_PASSWORD fields to + /usr/sbin/export-oracle and + change the SERVICE_NAME and + DATABASE_PASSWORD fields to their correct values. If you want to use a directory other than - /ora8/m02/oracle-exports, you + /ora8/m02/oracle-exports, you also need to change the - exportdir setting. + exportdir setting.

    Test the export procedure by running the command:

    @@ -164,12 +164,12 @@
     Export terminated successfully without warnings.

    If you don't have any warnings, proceed to automate the backups.

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

    - While still root, run the + crontab facility.

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

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

    Now add the following line on a line by itself

    @@ -179,32 +179,32 @@
     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

+; Logout

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

Set up nightly Postgres exports

(This is not required for the Reference install.) Dowload this script - to /tmp. At the top of the script + to /tmp. At the top of the script are several variables that you'll need to customize:

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

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

  • - ftp_user - username on your ftp + ftp_user - username on your ftp account

  • - ftp_password - password on your + ftp_password - password on your ftp account

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

  • - ftp_server - your ftp server + ftp_server - your ftp server

Next, we'll save this file to our server's - tcl directory so that it will be + 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.