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 @@ -
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]#
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.
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
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.
Earlier strategies, included here because this section - hasn't been fully updated yet.
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.
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) -
If you are already using CVS, you probably don't + [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.
+ 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