help in backup script

Hello folks.

Good Day!

i want to backup /var/www directory backup to another system daily basis incremental backup and weekly full backup. Directory name where it should automatically created like 2010-04-20 i mean via script. Can some one help?

try rsync...

read the man pages of the utility "rsynch"

i hope this can help you
this perl script copy files in the folder from $bkpath to $archpath in a folder with the today date as example:

/path/device/backup/file .txt
to
/path/device/archive/20100420/file.txt

Greets

#!/usr/bin/perl -w

#############################################
### Date:    09.04.2010                   ###
### Version: 1.0                          ###
### File:    jun_arch.pl                  ###
#############################################

use warnings;
use File::Copy;
### define in this file your paths like $archpath or $bkpath etc.
require "/path/backup.conf";

### get date
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
my ($date);
$date = sprintf"%4d%02d%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec;


print $archpath." ".length($bkppath)."\n";
        
my $createfolder = $archpath."".$date;

print $createfolder."\n";

### create folder with admin rights
mkdir("$createfolder",0755);


### find files and sub-folders in a folder
my @files;
my $path = $bkppath;

opendir(DIR, $path) or die "cant find $path: $!";
while (defined(my $file = readdir(DIR))) {
        next if $file =~ /^\.\.?$/;
        if ("$path$file"){
                push @files,"$path$file";
        }
}
closedir(DIR);

### use files and subfolder from an array

foreach my $i (@files){
        
        # use only config files
        if($i =~ m/.txt/){
                                 
         # find out the length of the filename
         my $len = length($i)-length($bkppath);

         # pars filename from path
         my $sub = substr($i,length($bkppath),$len);
                 
                 # strip out .txt
                 my $filename = substr($sub,0,(length($sub)-4));
                 
                 my $file_new = "$archpath$date/$filename-$date.cfg";
                 
                 print "move $i to $file_new\n";
                 move($i,$file_new);
                 
         }
}

Can you please clear, how to define path in that file.

make a new file which is in that directory and names which you define here:

### define in this file your paths like $archpath or $bkpath etc.
require "/path/backup.conf";

as example create file backup.conf in path

and backup.conf can look like this:

##################################################   #
# please use full path information to ensure     #
# that the procedure is working correctly        #
##################################################


# backup path
$bkppath = "/system/backup/device/";

# archive path
$archpath = "/system/backup/device/archive/";

backup.conf (END) 

I hope it helps you

Greets
Fraggy

It is not working

cat backup.conf

$bkpath = "/mnt/slave/1";
$archpath = "/etc/";

Use of uninitialized value in length at backup.pl line 20.
/etc/ 0
/etc/20100420
Use of uninitialized value in opendir at backup.pl line 34.
Use of uninitialized value in concatenation (.) or string at backup.pl line 34.
cant find : No such file or directory at backup.pl line 34.

please specify your error this text is weird x)

This problem come when i run script.

# perl backup.pl
Use of uninitialized value in length at backup.pl line 20.
/etc/ 0
/etc/20100420
Use of uninitialized value in opendir at backup.pl line 34.
Use of uninitialized value in concatenation (.) or string at backup.pl line 34.
cant find : No such file or directory at backup.pl line 34.