View Single Post
  #3  
Old 13th October 2008, 20:56
mccharlet mccharlet is offline
Senior Member
 
Join Date: Feb 2007
Posts: 262
Thanks: 65
Thanked 13 Times in 8 Posts
Default

Hi

I have modify the backup script to redirect the backup to /backup

I have change this

HTML Code:
                // Move file in /backup directory
//                $backup_dir = $httpd_root ."/web".$web_id."/backup";
                $backup_dir = "/backup/web".$web_id;
//                $web_user = fileowner($web_pfad);
//                $web_group = filegroup($web_pfad);
                if(!@is_dir($backup_dir)) {
                  mkdir($backup_dir,0755);
                } else {
                  exec("rm -rf $backup_dir/*");
                }
/*                if(@fileowner($backup_dir) != $web_user) {
                  chown($backup_dir,$web_user);
                }
                if(@filegroup($backup_dir) != $web_group) {
                  chgrp($backup_dir,$web_group);
                }
*/
I have create a perl script for moving the backup file to the same folder and rename them

HTML Code:
#!/usr/bin/perl
$repertoire = @ARGV[0];
$rep_backup= @ARGV[1];
$fichier_log= @ARGV[2];

open LOG,">".$fichier_log;
if ( @ARGV != 3 )
{
        print "\nSyntax: perl mv-backup.pl repertoire_sources repertoire_dest fichier_log \n\n";
        exit 1;
}

if (substr($repertoire,length($repertoire)-1) ne "/"){
        $repertoire = $repertoire."/";
}

#lecture des fichiers d'un repertoire
opendir REP,$repertoire or die "impossible d'ouvrir le repertoire";
@fichiers = readdir REP;
closedir REP;
foreach $fichier (@fichiers){
        $prefixe= $fichier."_";
        $fichier = $repertoire.$fichier;

        if (($fichier ne $repertoire."..") and ($fichier ne $repertoire.".") and (-d $fichier)){
                $fichier=$fichier."/";
                opendir REP,$fichier or die "impossible d'ouvrir le repertoire";
                @fichiers2 = readdir REP;
                closedir REP;

          foreach $fichier2 (@fichiers2){
                        $nom_fichier = $fichier2;
                        $fichier2 = $fichier.$fichier2;
                        if (-f $fichier2){
                                print LOG "$fichier2\n";

                                rename $fichier2,$rep_backup.$prefixe.$nom_fichier;
                                print $fichier2,$rep_backup.$prefixe.$nom_fichier."\n\r";
                        }
                }

        }
}
close LOG;
perl mv-backup.pl /backup/ /sites/ log_file_mv.txt

And with this command i delete older than four days
find /sites/ -mtime +4 -exec rm {} \;
__________________
Thanks
CÚdric

Sorry for my english

Hosting : http://www.jheberge.ch
Reply With Quote