Index: openacs-4/packages/acs-core-docs/www/snapshot-backup.html =================================================================== RCS file: /usr/local/cvsroot/openacs-4/packages/acs-core-docs/www/snapshot-backup.html,v diff -u -r1.6 -r1.6.2.1 --- openacs-4/packages/acs-core-docs/www/snapshot-backup.html 16 Feb 2005 00:21:03 -0000 1.6 +++ openacs-4/packages/acs-core-docs/www/snapshot-backup.html 26 Aug 2005 00:02:30 -0000 1.6.2.1 @@ -1,4 +1,4 @@ -Manual backup and recovery

Manual backup and recovery

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

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 @@ -7,28 +7,28 @@ including the AOLserver config files, is then in tree for regular file system backup.

  1. Back up the database to a file.�

    • Oracle.�

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

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

        [joeuser ~]$ su -
        -[root ~]# cp /var/tmp/export-oracle.txt /usr/sbin/export-oracle
        -[root ~]# chmod 700 /usr/sbin/export-oracle
      • +

        [joeuser ~]$ su -
        +[root ~]# cp /var/tmp/export-oracle.txt /usr/sbin/export-oracle
        +[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.

        [root ~]# mkdir /ora8/m02/oracle-exports
        -[root ~]# chown oracle:dba /ora8/m02/oracle-exports
        -[root ~]# chmod 770 /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: -

        [root ~]# /usr/sbin/export-oracle
        +              

        [root ~]# /usr/sbin/export-oracle
         mv: /ora8/m02/oracle-exports/oraexport-service_name.dmp.gz: No such file or directory
         
         Export: Release 8.1.6.1.0 - Production on Sun Jun 11 18:07:45 2000
        @@ -63,70 +63,70 @@
           . 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 root]# su - $OPENACS_SERVICE_NAME
      -[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ pg_dump -f /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/before_upgrade_to_4.6.dmp $OPENACS_SERVICE_NAME
      -[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ ls -al /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/before_upgrade_to_4.6.dmp 
      +Export terminated successfully without warnings.
  2. PostgreSQL.�Create a backup file and verify that it was created and has a reasonable size (several megabytes).

    [root root]# su - $OPENACS_SERVICE_NAME
    +[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ pg_dump -f /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/before_upgrade_to_4.6.dmp $OPENACS_SERVICE_NAME
    +[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ ls -al /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/before_upgrade_to_4.6.dmp 
     -rw-rw-r-x    1 $OPENACS_SERVICE_NAME  $OPENACS_SERVICE_NAME   4005995 Feb 21 18:28 /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/before_upgrade_to_4.6.dmp
    -[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ exit
    +[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ exit
     [root root]#
     su - $OPENACS_SERVICE_NAME
     pg_dump -f /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/before_upgrade_to_4.6.dmp openacs-dev
     ls -al /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/before_upgrade_to_4.6.dmp
     exit
  • Back up the file system.�Back up all of the files in the service, including the database backup file but excluding the auto-generated - supervise directory, which is - unneccesary and has complicated permissions.

    In the tar command,

    • c create a - new tar archive

    • p preserves permissions.

    • s preserves file sort order

    • z compresses the output with gzip.

    • The --exclude clauses skips some daemontools files that + supervise directory, which is + unneccesary and has complicated permissions.

      In the tar command,

      • c create a + new tar archive

      • p preserves permissions.

      • s preserves file sort order

      • z compresses the output with gzip.

      • The --exclude clauses skips some daemontools files that are owned by root and thus cannot be backed up by the service owner. These files are autogenerated and we don't - break anything by omitting them.

      • The --file clause + break anything by omitting them.

      • The --file clause specifies the name of the output file to be generated; we manually add the correct extensions.

      • The last clause, - /var/lib/aolserver/$OPENACS_SERVICE_NAME/, + /var/lib/aolserver/$OPENACS_SERVICE_NAME/, specifies the starting point for backup. Tar defaults to - recursive backup.

      [root root]# su - $OPENACS_SERVICE_NAME
      -[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ tar -cpsz --exclude /var/lib/aolserver/$OPENACS_SERVICE_NAME/etc/daemontools/supervise \
      -   --file /var/tmp/$OPENACS_SERVICE_NAME-backup.tar.gz /var/lib/aolserver/$OPENACS_SERVICE_NAME/
      +            recursive backup.

    [root root]# su - $OPENACS_SERVICE_NAME
    +[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ tar -cpsz --exclude /var/lib/aolserver/$OPENACS_SERVICE_NAME/etc/daemontools/supervise \
    +   --file /var/tmp/$OPENACS_SERVICE_NAME-backup.tar.gz /var/lib/aolserver/$OPENACS_SERVICE_NAME/
     tar: Removing leading `/' from member names
    -[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$
  • Suffer a catastrophic failure on your production system.�(We'll simulate this step)

    [root root]# svc -d /service/$OPENACS_SERVICE_NAME
    -[root root]# mv /var/lib/aolserver/$OPENACS_SERVICE_NAME/ /var/lib/aolserver/$OPENACS_SERVICE_NAME.lost
    -[root root]# rm /service/$OPENACS_SERVICE_NAME
    +[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$
  • Suffer a catastrophic failure on your production system.�(We'll simulate this step)

    [root root]# svc -d /service/$OPENACS_SERVICE_NAME
    +[root root]# mv /var/lib/aolserver/$OPENACS_SERVICE_NAME/ /var/lib/aolserver/$OPENACS_SERVICE_NAME.lost
    +[root root]# rm /service/$OPENACS_SERVICE_NAME
     rm: remove symbolic link `/service/$OPENACS_SERVICE_NAME'? y
    -[root root]# ps -auxw | grep $OPENACS_SERVICE_NAME
    +[root root]# ps -auxw | grep $OPENACS_SERVICE_NAME
     root      1496  0.0  0.0  1312  252 ?        S    16:58   0:00 supervise $OPENACS_SERVICE_NAME
    -[root root]# kill 1496
    -[root root]# ps -auxw | grep $OPENACS_SERVICE_NAME
    -[root root]# su - postgres
    -[postgres pgsql]$ dropdb $OPENACS_SERVICE_NAME
    +[root root]# kill 1496
    +[root root]# ps -auxw | grep $OPENACS_SERVICE_NAME
    +[root root]# su - postgres
    +[postgres pgsql]$ dropdb $OPENACS_SERVICE_NAME
     DROP DATABASE
    -[postgres pgsql]$ dropuser $OPENACS_SERVICE_NAME
    +[postgres pgsql]$ dropuser $OPENACS_SERVICE_NAME
     DROP USER
    -[postgres pgsql]$ exit
    +[postgres pgsql]$ exit
     logout
     [root 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. Recreate the service user ($OPENACS_SERVICE_NAME).

    2. Restore the OpenACS files and database backup file.

      [root root]# su - $OPENACS_SERVICE_NAME
      -[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ cd /var/lib/aolserver
      -[$OPENACS_SERVICE_NAME aolserver]$ tar xzf /var/tmp/$OPENACS_SERVICE_NAME-backup.tar.gz
      -[$OPENACS_SERVICE_NAME aolserver]$ chmod -R 775 $OPENACS_SERVICE_NAME
      -[$OPENACS_SERVICE_NAME aolserver]$ chown -R $OPENACS_SERVICE_NAME.web $OPENACS_SERVICE_NAME
    3. Restore the database

      • Oracle.�

        1. Set up a clean Oracle database user and - tablespace with the same names as the ones exported from (more information).

        2. Invoke the import command

          imp $OPENACS_SERVICE_NAME/$OPENACS_SERVICE_NAME FILE=/var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/nighty_backup.dmp FULL=Y
      • Postgres.�If the database user does not already exist, create it.

        [root root]# su - postgres
        -[postgres ~]$ createuser $OPENACS_SERVICE_NAME
        -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
        +            guide.  Recreate the service user ($OPENACS_SERVICE_NAME).

      • Restore the OpenACS files and database backup file.

        [root root]# su - $OPENACS_SERVICE_NAME
        +[$OPENACS_SERVICE_NAME $OPENACS_SERVICE_NAME]$ cd /var/lib/aolserver
        +[$OPENACS_SERVICE_NAME aolserver]$ tar xzf /var/tmp/$OPENACS_SERVICE_NAME-backup.tar.gz
        +[$OPENACS_SERVICE_NAME aolserver]$ chmod -R 775 $OPENACS_SERVICE_NAME
        +[$OPENACS_SERVICE_NAME aolserver]$ chown -R $OPENACS_SERVICE_NAME.web $OPENACS_SERVICE_NAME
      • Restore the database

        • Oracle.�

          1. Set up a clean Oracle database user and + tablespace with the same names as the ones exported from (more information).

          2. Invoke the import command

            imp $OPENACS_SERVICE_NAME/$OPENACS_SERVICE_NAME FILE=/var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/nighty_backup.dmp FULL=Y
        • Postgres.�If the database user does not already exist, create it.

          [root root]# su - postgres
          +[postgres ~]$ createuser $OPENACS_SERVICE_NAME
          +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 ~]$ exit
          -

          Because of a bug in Postgres backup-recovery, database objects are not guaranteed to be created in the right order. In practice, running the OpenACS initialization script is always sufficient to create any out-of-order database objects. Next, restore the database from the dump file. The restoration will show some error messages at the beginning for objects that were pre-created from the OpenACS initialization script, which can be ignored.

          [root root]# su - $OPENACS_SERVICE_NAME
          -[$OPENACS_SERVICE_NAME ~]$ createdb $OPENACS_SERVICE_NAME
          +[postgres ~]$ exit
          +

          Because of a bug in Postgres backup-recovery, database objects are not guaranteed to be created in the right order. In practice, running the OpenACS initialization script is always sufficient to create any out-of-order database objects. Next, restore the database from the dump file. The restoration will show some error messages at the beginning for objects that were pre-created from the OpenACS initialization script, which can be ignored.

          [root root]# su - $OPENACS_SERVICE_NAME
          +[$OPENACS_SERVICE_NAME ~]$ createdb $OPENACS_SERVICE_NAME
           CREATE DATABASE
          -[$OPENACS_SERVICE_NAME ~]$ psql -f /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/acs-kernel/sql/postgresql/postgresql.sql $OPENACS_SERVICE_NAME
          +[$OPENACS_SERVICE_NAME ~]$ psql -f /var/lib/aolserver/$OPENACS_SERVICE_NAME/packages/acs-kernel/sql/postgresql/postgresql.sql $OPENACS_SERVICE_NAME
           (many lines omitted)
          -[$OPENACS_SERVICE_NAME ~]$ psql $OPENACS_SERVICE_NAME < /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/database-backup.dmp
          +[$OPENACS_SERVICE_NAME ~]$ psql $OPENACS_SERVICE_NAME < /var/lib/aolserver/$OPENACS_SERVICE_NAME/database-backup/database-backup.dmp
           (many lines omitted)
          -[$OPENACS_SERVICE_NAME ~]$ exit
          -[postgres ~]$ exit
          -logout
      • Activate the service

        [root root]# ln -s /var/lib/aolserver/$OPENACS_SERVICE_NAME/etc/daemontools /service/$OPENACS_SERVICE_NAME
        -[root root]# sleep 10
        -[root root]# svgroup web /service/$OPENACS_SERVICE_NAME
  • View comments on this page at openacs.org
    +[$OPENACS_SERVICE_NAME ~]$ exit +[postgres ~]$ exit +logout
  • Activate the service

    [root root]# ln -s /var/lib/aolserver/$OPENACS_SERVICE_NAME/etc/daemontools /service/$OPENACS_SERVICE_NAME
    +[root root]# sleep 10
    +[root root]# svgroup web /service/$OPENACS_SERVICE_NAME
  • View comments on this page at openacs.org