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.5 -r1.6 --- openacs-4/packages/acs-core-docs/www/backup-recovery.html 14 Oct 2003 11:02:57 -0000 1.5 +++ openacs-4/packages/acs-core-docs/www/backup-recovery.html 21 Oct 2003 10:04:47 -0000 1.6 @@ -33,31 +33,31 @@ OpenACS installations comprise files and database contents. If you follow the reference install and put all files, including configuration files, in - /web/service0/, + /var/lib/aolserver/service0/, and back up the database nightly to a file in - /web/service0/database-backup, + /var/lib/aolserver/service0/database-backup, then you can apply standard file-based backup strategies to - /web/service0 + /var/lib/aolserver/service0

Snapshot backup and recovery

This section describes how to make a one-time backup 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.

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 + /var/lib/aolserver/service0/database-backup so that the tar command will include the database.

In the tar command,

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

Automated Backup (OPTIONAL)

Backup can encompass all files in - /web/service0. For a development + /var/lib/aolserver/service0. For a development server, putting the files in cvs, and backing up the database nightly, is sufficient. (It's important then to back up the cvs repository!)

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. A quick way to automate database backup is a cron job. This @@ -143,8 +143,8 @@ single nightly backup file which is then collected into a bigger backup file that includes the other parts of the service (web pages, content, code). 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 /web/service0/database-backup/service0_$(date +%Y-%m-%d).dmp service0

If you plan to back up the whole /web/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 /web/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.

Delete the Service

[root@yourserver root]# svc -d /service/service0
-[root@yourserver root]# mv /web/service0/ /web/service0.lost
+        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.

Delete the Service

[root@yourserver root]# svc -d /service/service0
+[root@yourserver root]# mv /var/lib/aolserver/service0/ /var/lib/aolserver/service0.lost
 [root@yourserver root]# rm /service/service0
 rm: remove symbolic link `/service/service0'? y
 [root@yourserver root]# ps -auxw | grep service0
@@ -170,24 +170,24 @@
 logout
 
 [root@yourserver root]# su - service0
-[service0@yourserver service0]$ cd /web
+[service0@yourserver service0]$ cd /var/lib/aolserver
 [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 /var/lib/aolserver/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 < /var/lib/aolserver/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]# 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]#

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/service0/database-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 @@ -275,7 +275,7 @@ 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 crontab backup. +; 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: @@ -304,7 +304,7 @@ midnight. Note that this script only backs up the database - not the OpenACS scripts and file content.

-joeuser:~$ cp /tmp/acs-pgbackup-init.txt ~/web/birdnotes/tcl/acs-pgbackup-init.tcl
+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)