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.4 -r1.15.2.5 --- openacs-4/packages/acs-core-docs/www/backup-recovery.html 8 Dec 2003 15:41:16 -0000 1.15.2.4 +++ openacs-4/packages/acs-core-docs/www/backup-recovery.html 15 Dec 2003 15:03:46 -0000 1.15.2.5 @@ -49,16 +49,16 @@
Login as root. The following commands will install the export script:
- joeuser:~$ su - + [joeuser ~]$ su - Password: *********** - root:~# cp /tmp/export-oracle.txt /usr/sbin/export-oracle - root:~# chmod 700 /usr/sbin/export-oracle
+ [root ~]# cp /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
+ [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 @@ -70,7 +70,7 @@
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 @@ -106,16 +106,16 @@ . 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 - [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 + 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 - service0
+ [service0 service0]$ pg_dump -f /var/lib/aolserver/service0/database-backup/before_upgrade_to_4.6.dmp service0
+ [service0 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
- [service0@localhost service0]$ exit
- [root@localhost root]#
- su - service0
+ [service0 service0]$ exit
+ [root root]#
+ su - service0
pg_dump -f /var/lib/aolserver/service0/database-backup/before_upgrade_to_4.6.dmp openacs-dev
ls -al /var/lib/aolserver/service0/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 + 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 @@ -127,81 +127,81 @@ manually add the correct extensions.
The last clause, /var/lib/aolserver/service0/, specifies the starting point for backup. Tar defaults to - recursive backup.
[root@yourserver root]# su - service0 - [service0@yourserver service0]$ tar -cpsj --exclude /var/lib/aolserver/service0/etc/daemontools/supervise --file /tmp/service0-backup.tar.bz2 /var/lib/aolserver/service0/ + recursive backup.
[root root]# su - service0 + [service0 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]$
Suffer a catastrophic failure on your production system.�(We'll simulate this step)
[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 + [service0 service0]$
Suffer a catastrophic failure on your production system.�(We'll simulate this step)
[root root]# svc -d /service/service0 + [root root]# mv /var/lib/aolserver/service0/ /var/lib/aolserver/service0.lost + [root root]# rm /service/service0 rm: remove symbolic link `/service/service0'? y - [root@yourserver root]# ps -auxw | grep service0 + [root 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 root]# kill 1496 + [root root]# ps -auxw | grep service0 + [root root]# su - postgres + [postgres pgsql]$ dropdb service0 DROP DATABASE - [postgres@yourserver pgsql]$ dropuser service0 + [postgres pgsql]$ dropuser service0 DROP USER - [postgres@yourserver pgsql]$ exit + [postgres pgsql]$ exit logout - [root@yourserver root]#
Restore the operating system and required software. + [root root]#
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 (service0).
Restore the OpenACS files and database backup file.
[root@yourserver root]# su - service0 - [service0@yourserver service0]$ cd /var/lib/aolserver - [service0@yourserver aolserver]$ tar xjf /tmp/service0-backup.tar.bz2 - [service0@yourserver aolserver]$ chmod -R 775 service0 - [service0@yourserver aolserver]$ chown -R service0.web service0 + guide. Recreate the service user (service0).
Restore the OpenACS files and database backup file.
[root root]# su - service0 + [service0 service0]$ cd /var/lib/aolserver + [service0 aolserver]$ tar xjf /tmp/service0-backup.tar.bz2 + [service0 aolserver]$ chmod -R 775 service0 + [service0 aolserver]$ chown -R service0.web service0
Restore the database
Oracle.�
Set up a clean Oracle database user and - tablespace (more information).
Invoke the import command
imp service0/service0 FILE=/var/lib/aolserver/service0/database-backup/nighty_backup.dmp
Postgres.�
Because of a bug in Postgres backup-recovery, database objects are not guaranteed to be created in the right order. To compensate, we pre-creating some critical items first, which leads to some harmless errors.
[root@yourserver root]# su - postgres - [postgres@yourserver pgsql]$ createuser service0 + tablespace with the same names as the ones exported from (more information).
Invoke the import command
imp service0/service0 FILE=/var/lib/aolserver/service0/database-backup/nighty_backup.dmp FULL=Y
Postgres.�
Because of a bug in Postgres backup-recovery, database objects are not guaranteed to be created in the right order. To compensate, we pre-creating some critical items first, which leads to some harmless errors.
[root root]# su - postgres + [postgres 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 - [service0@yourserver web]$ createdb service0 + [service0 web]$ createdb service0 CREATE DATABASE - [service0@yourserver web]$ psql -f /var/lib/aolserver/service0/packages/acs-kernel/sql/postgresql/postgresql.sql service0 + [service0 web]$ psql -f /var/lib/aolserver/service0/packages/acs-kernel/sql/postgresql/postgresql.sql service0 (many lines omitted) - [service0@yourserver web]$ psql service0 < /var/lib/aolserver/service0/database-backup/database-backup.dmp + [service0 web]$ psql service0 < /var/lib/aolserver/service0/database-backup/database-backup.dmp (many lines omitted) - [service0@yourserver web]$ exit - [postgres@yourserver pgsql]$ exit + [service0 web]$ exit + [postgres pgsql]$ exit logout -
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]#
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.
Make sure that the manual backup process described above works.
Customize the default backup script. Edit /var/lib/aolserver/service0/etc/backup.sh with your specific parameters.
+
Activate the service
[root root]# ln -s /var/lib/aolserver/service0/etc/daemontools /service/service0 + [root root]# sleep 10 + [root root]# svgroup web /service/service0 + [root root]#
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.
Make sure that the manual backup process described above works.
Customize the default backup script. Edit /var/lib/aolserver/service0/etc/backup.sh with your specific parameters.
Make sure the file is executable:
chmod +x backup.sh
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
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 current system time, down to the minute. For maximum safety, you can apply a tag to your current - files. You will still need to back up your database.
Note that, if you did the CVS options in this document, the /var/lib/aolserver/service0/etc directory is not included in cvs and you may want to add it.
[root@localhost root]# su - service0 - [service0@localhost service0]$ cd /var/lib/aolserver/service0 - [service0@localhost service0]$ cvs commit -m "last-minute commits before upgrade to 4.6" + files. You will still need to back up your database.Note that, if you did the CVS options in this document, the /var/lib/aolserver/service0/etc directory is not included in cvs and you may want to add it.
[root root]# su - service0 + [service0 service0]$ cd /var/lib/aolserver/service0 + [service0 service0]$ cvs commit -m "last-minute commits before upgrade to 4.6" cvs commit: Examining . cvs commit: Examining bin (many lines omitted) - [service0@localhost service0]$ cvs tag before_upgrade_to_4_6 + [service0 service0]$ cvs tag before_upgrade_to_4_6 cvs server: Tagging bin T bin/acs-4-0-publish.sh T bin/ad-context-server.pl (many lines omitted) - [service0@localhost service0]$ exit - [root@localhost root]# -su - service0 + [service0 service0]$ exit + [root root]# + su - service0 cd /var/lib/aolserver/service0 cvs commit -m "last-minute commits before upgrade to 4.6" cvs tag before_upgrade_to_4_6 - exit
To restore files from a cvs tag such as the one used above:
[root@localhost root]# su - service0 - [service0@localhost service0]$ cd /var/lib/aolserver/service0 - [service0@localhost service0]$ cvs up -r current - [service0@localhost service0]$ exit -su - service0 + exit
To restore files from a cvs tag such as the one used above:
[root root]# su - service0 + [service0 service0]$ cd /var/lib/aolserver/service0 + [service0 service0]$ cvs up -r current + [service0 service0]$ exit + su - service0 cd /var/lib/aolserver/service0 - cvs up -r current