[vhffs-dev] [1464] code cleaning

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 1464
Author:   gradator
Date:     2009-06-29 23:00:40 +0200 (Mon, 29 Jun 2009)

Log Message:
-----------
code cleaning

Modified Paths:
--------------
    trunk/vhffs-robots/src/mysql_dump.pl


Modified: trunk/vhffs-robots/src/mysql_dump.pl
===================================================================
--- trunk/vhffs-robots/src/mysql_dump.pl	2009-06-29 19:32:26 UTC (rev 1463)
+++ trunk/vhffs-robots/src/mysql_dump.pl	2009-06-29 21:00:40 UTC (rev 1464)
@@ -47,38 +47,30 @@
 
 my $vhffs = init Vhffs::Main; 
 
-Vhffs::Robots::lock( $vhffs , "dumpmysql" );
+Vhffs::Robots::lock( $vhffs , 'dumpmysql' );
 
-my $objs  = Vhffs::Services::Mysql::getall( $vhffs , Vhffs::Constants::ACTIVATED , undef , undef );
 my $mysqlconf = $vhffs->get_config->get_service('mysql');
+die 'Error, mysqldump is not present on this system in path "'.$mysqlconf->{'mysqldump_path'}.'"'."\n" unless( -x $mysqlconf->{'mysqldump_path'} );
 
-my $obj;
-my $group;
-my $groupname;
+umask 0337;
 
-die "Error, mysqldump is not present on this system in path \"$mysqlconf->{'mysqldump_path'}\"\n" unless( -x $mysqlconf->{'mysqldump_path'} );
-
-foreach $obj ( @{$objs} )
+my $objs  = Vhffs::Services::Mysql::getall( $vhffs , Vhffs::Constants::ACTIVATED , undef , undef );
+foreach my $obj ( @{$objs} )
 {
-		$groupname = Vhffs::Group::get_name_by_gid( $vhffs , $obj->get_owner_gid );
-		my $dbname = $obj->get_dbname;
-		my $dir = Vhffs::Functions::hash_groupname( $groupname , $vhffs );
-		if( -d $dir )
-		{
-			my $file = $dir."/".$dbname.".mysql.dump";
-			my $cmd = "$mysqlconf->{'mysqldump_path'} -c -R --hex-blob -u $mysqlconf->{'username'} -h $mysqlconf->{'host'} -p$mysqlconf->{'password'} $dbname > $file";
-			system( $cmd );
+	my $groupname = Vhffs::Group::get_name_by_gid( $vhffs , $obj->get_owner_gid );
+	my $dbname = $obj->get_dbname;
 
-			#Change the chmod if the backup succeed
-			if( -f $file )
-			{
-				chown( $obj->get_owner_uid , $obj->get_owner_gid , $file );
-				chmod( 0660 , $file );
-			}
-			
-		}
+	my $dir = Vhffs::Functions::hash_groupname( $groupname , $vhffs );
+	next unless -d $dir;
+
+	my $file = $dir.'/'.$dbname.'.mysql.dump';
+	my $cmd = $mysqlconf->{'mysqldump_path'}.' -c -R --hex-blob -u '.$mysqlconf->{'username'}.' -h '.$mysqlconf->{'host'}.' -p'.$mysqlconf->{'password'}.' '.$dbname.' > '.$file;
+
+	system( $cmd );
+
+	chown( $obj->get_owner_uid , $obj->get_owner_gid , $file ) if -f $file;
 }
 
-Vhffs::Robots::unlock( $vhffs , "dumpmysql" );
+Vhffs::Robots::unlock( $vhffs , 'dumpmysql' );
 
 exit 0;


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/