Index: [Article Count Order] [Thread]

Date:  Fri, 30 Nov 2007 11:25:12 +0100
From:  =?ISO-8859-1?Q?Ren=E9_M=F8lsted?= <molsted (at mark) iweb.dk>
Subject:  [coba-e:11323] Re: backup
To:  coba-e (at mark) bluequartz.org
Message-Id:  <8FE1E490-395C-4CE9-81FB-7F49FE73A599 (at mark) iweb.dk>
In-Reply-To:  <007c01c83309$b06c02d0$6700a8c0@OfficeKen>
References:  <03a101c8327b$f7f342a0$0101a8c0 (at mark) systemax> <474EF81C.1080708 (at mark) nomealaska.org> <474F1A16.7020808 (at mark) nomealaska.org> <016a01c832cd$da1801b0$6400a8c0 (at mark) HPPAVILION> <474F5D0E.1070704 (at mark) nomealaska.org> <01ed01c832f6$94936390$6400a8c0 (at mark) HPPAVILION> <007c01c83309$b06c02d0$6700a8c0 (at mark) OfficeKen>
X-Mail-Count: 11323

On 30/11/2007, at 5.30, Ken Marcus - Precision Web Hosting, Inc. wrote:

> Here is a script that will take a list of sites from a file named  
> "sitestoadd.txt" and will restore them to a server. Using this  
> script, if you have a problem half way through a restore like a  
> memory leak or disconnection problem, you won't have to start all  
> over.  Just log back in, edit the sitestoadd.txt and start it again.

Couldn't that be handled by restarting cced for every n site?
Eg. for every 20 site

Just found this in my "needs-to-be-tested"-folder
BE AWARE THAT THIS HAS NOT BEEN TESTED IN ANY WAY!!!!


#/usr/bin/perl

$BASEDIR = "/home/restore" ; #The location of restore data
$PREFIX = "groups-" ; # Used to grab the host- & domainname
$SUFFIX = "-public.tar.gz" ; # Used to grab the host- & domainname
$count = 1 ; # Sets the site count to 1
$CCED = 20 ; # Restart the cced for n sites

chdir("$BASEDIR") || die "Cannot chdir to $BASEDIR ($!)" ;

opendir(COUNTSITES, "$BASEDIR") || die "Cannot opendir $BASEDIR: $!" ;

foreach $COUNT (sort readdir(COUNTSITES)) {
	if (($COUNT =~ m/^($PREFIX)/) && ($COUNT =~ m/($SUFFIX)$/)) {
		$totalcount++;
	}
}

closedir(SITES);

print "Importing a total of $totalcount sites ...\n";

opendir(SITES, "$BASEDIR") || die "Cannot opendir $BASEDIR: $!" ;

foreach $SITE (sort readdir(SITES)) {
	if (($SITE =~ m/^($PREFIX)/) && ($SITE =~ m/($SUFFIX)$/)) {
		$SITE =~ s/${PREFIX}//g ;
		$SITE =~ s/${SUFFIX}//g ;
		print "Importing site: $SITE ($count/$totalcount)\n";
		system ("/usr/sbin/cmuImport -d $BASEDIR -n $SITE") ;
		
		if ($count % $CCED == 0) {
			print "Restarting the cced to prevent memory leak on large imports 
\n";
			system ("/etc/rc.d/init.d/cced.init restart") ;
		}
		$count++
	}
}

closedir(SITES);

print "Importing is now done - Restarting the cced ...\n";
system ("/etc/rc.d/init.d/cced.init restart") ;
system ("/etc/rc.d/init.d/cced.init status") ;