help in backup script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting help in backup script
# 1  
Old 04-20-2010
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?
# 2  
Old 04-20-2010
try rsync...

read the man pages of the utility "rsynch"
# 3  
Old 04-20-2010
Hope it helps you

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

Code:
#!/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);
                 
         }
}

# 4  
Old 04-20-2010
Can you please clear, how to define path in that file.
# 5  
Old 04-20-2010
Bug Backup.conf

Quote:
Originally Posted by learnbash
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:
Code:
### 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:
Code:
##################################################   #
# 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
# 6  
Old 04-20-2010
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.
# 7  
Old 04-20-2010
Question

Quote:
Originally Posted by learnbash
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)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Backup Script

I don't know how to repair this script :/ My OS: Ubuntu Server 18.04 "Bionic Beaver" LTS (64bits) #!/bin/bash # ### Ustawienia - sciezki do plików ### DIRS="/home/ts/ /home/mc/" BACKUP=/home/backup.$$ NOW=$(date +"%d-%m-%Y") DELDATE=$(date -d "-7 days" +"%d-%m-%Y") DAY=$(date +"%a") #... (4 Replies)
Discussion started by: xCraftRayX
4 Replies

2. Shell Programming and Scripting

Backup Script

I have write the following script, its execution i got following error: !/bin/sh # # dy='date +%d%b%y' hn="ECTMPROD12" bk='/home/backup' sb=$bk'/'$hn # # cm_d01='tar -czf /home/backup/'$hn'_'$dy'_ofhome.tar.gz /home/oracle/ofhome' # # echo "***** start time of ECTMPROD12 backup full"... (3 Replies)
Discussion started by: rizwan.shaukat
3 Replies

3. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

4. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

5. Shell Programming and Scripting

Backup script / Test if script is already running

Hello everyone, I have 2 questions : 1) I have a backup shell script, let's call it backup.sh, that is called every hour as a cron job. As a matter of fact a backup could last more than one hour. It mounts a NAS and then do some rsync on important directories, so really I don't want to... (2 Replies)
Discussion started by: freddie50
2 Replies

6. Shell Programming and Scripting

Need help in creating file restoration script from a backup script.

Hi all i am struggling in creating a restore of env files while doing applications clone. the first file i created for copying the important configurations file which is running perfect now for reverting the changes i mean when i am restoring these files to its original places i have to do... (7 Replies)
Discussion started by: javeedkaleem
7 Replies

7. Shell Programming and Scripting

rsync backup mode(--backup) Are there any options to remove backup folders on successful deployment?

Hi Everyone, we are running rsync with --backup mode, Are there any rsync options to remove backup folders on successful deployment? Thanks in adv. (0 Replies)
Discussion started by: MVEERA
0 Replies

8. Shell Programming and Scripting

backup script

Hi, I need to write a script that will capture the 8th character on each line (alphanumeric /meta chars) to the 16th character and send to an output file. Any ideas? R, D. (3 Replies)
Discussion started by: Duffs22
3 Replies

9. UNIX for Dummies Questions & Answers

Backup Script

Hi, My SCO Unixware 7.1.1 box is setup to run an EOD backup script, which is as follows: ---------------------------------------------------------------------- start End-of-day compress $BASE TO /home/compdir write /home/compdir to DATTAPE end ... (0 Replies)
Discussion started by: tayyabq8
0 Replies

10. AIX

Backup Script

I'm not sure if this is the place to ask this question but I have a script on an IBM RS6000 that has quit working. I can manually run a backup using SMIT and it appears okay, but not sure about the script. ----------code------------ #!/bin/ksh #set -x echo backup beginning date find... (7 Replies)
Discussion started by: geek4sur
7 Replies
Login or Register to Ask a Question