lovewht
06-27-2003, 09:16 AM
Hello,
I have a forum site. I want spend daily 15 minutes at 1 AM for backup databases. During that times I don't want my clients access the site, I want to changed my index file like "this site under maintenance". How can I do it? I known that use cron but I'm not clear how to do.
Thanks for your help.
datums
06-27-2003, 09:35 AM
1. Change the root directory of your site to /what/ever/docs/maintenance in here you would have your maintenance page.
2. Stop Apache Restart Apache
3. mysqladmin processlist -u root (make sure there are no connection to the db.
4. mysqldump the databases.
5.change the root directory.
6. your done.
If you don't change the root directory and simply change the index page , users will still be able to view other pages or sub directories.
serial
06-27-2003, 09:58 AM
In /home/username/public_html create a .htaccess.maintenance file with the following contents:RewriteEngine On
RewriteRule .* maintenance.html [L] In /home/username/public_html create a maintenance.html file with the following contents:The site is undergoing nightly maintenance. It should be back online within 15 minutes.In /home/username/ create a maintenance.sh file with the following contents:#!/bin/sh
date=`/bin/date +%m-%d-%Y`
/bin/mv -f /home/username/public_html/.htaccess /home/username/public_html/.htaccess.original
/bin/cp -f /home/username/public_html/.htaccess.maintenance /home/username/public_html/.htaccess
/usr/bin/mysqldump -uUSERNAME -pPASSWORD database > /home/username/database-backup-$date.sql
/bin/cp -f /home/username/public_html/.htaccess.original /home/username/public_html/.htaccessNext create the following cron:0 1 * * * /bin/sh /home/username/maintenance.sh 2>&1 >/dev/null