Sponsored Content
Top Forums Shell Programming and Scripting Archiving the Files in a folder Post 302394654 by vsmeruga on Friday 12th of February 2010 07:20:44 AM
Old 02-12-2010
Archiving the Files in a folder

My requirement is to put all the files from output directory(ATT) to archive directory(archive\) creating a new
folder with datetimestamp(20100212_120014) every time it runs.
where ${IMF_TARGET_DIR} is my base directory.
${IMF_ARCHIVE_DIR} is my Archive directory
IMF_TARGET_DIR=/grid/PowerCenter/stage/r3_dev/outbound/ATRPU # local target file directory
IMF_ARCHIVE_DIR=${IMF_TARGET_DIR}/archive # archive directory

I have 3 files and a folder called archive\ in my IMF_TARGET_DIR. And I have to keep these 3 files in new
timestamped archive folder. For that my shell script is as below. Andi am getting error as below

Code:
 
2010/02/12 12:01:47 : Running function archive_file 
/grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/ff_pre_sanity_check.bad
2010/02/12 12:01:47 : Running function archive_file 
/grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/ff_pre_sanity_check.out
2010/02/12 12:01:47 : Running function archive_file 
/grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/tgt_atu_rp.bad
2010/02/12 12:01:47 : Running function archive_file 
/grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/IMF_ATRPU_12022010114110.csv
2010/02/12 12:01:47 : ERROR : Failed to archive file 
/grid/PowerCenter/stage/velocity_r3_dev/outbound/ATRPU/IMF_ATRPU_12022010114110.csv

my shell script:
Code:
for file in `find ${IMF_TARGET_DIR} -type f `
do
  FN=`basename $file`
  echo ${FN} 
  # archive the input file after the workflow has completed
    co_call_function "archive_file ${IMF_TARGET_DIR}/${FN}"
done
archive_file()
{
     
    ${DEBUG}
    # local parameters
    local FILE_NAME=$1
      
    # create target system specific archive directory if it does not exist
    co_create_directory ${IMF_ARCHIVE_DIR}/${DATE_TIME} ${OSLOG}
    # archive the delivered data file
    cp ${FILE_NAME} ${IMF_ARCHIVE_DIR}/${DATE_TIME} 1>> ${OSLOG} 2>&1
    
    co_error_check $? "Failed to archive file ${FILE_NAME}"
}

Please help me .. it is very urgent to me.

Last edited by zaxxon; 02-12-2010 at 08:25 AM.. Reason: use code tags
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Backing up or Archiving files in UNIX

Hi All, I am very new to the UNIX world and find myself in a new position at work that requires me to archive large CADD files based in both UNIX and Windows environments on CD's. I have one engineer that wants to export these files as a table (I guess) and it appears to have a lot of paper... (2 Replies)
Discussion started by: Dsartelle
2 Replies

2. Shell Programming and Scripting

Archiving and moving the files

hi all i have a requirement where in i have to zip all the files with "*.bkp" after 14 days and move the zip files to Archive directory .... i am able to achieve the first functionality but not able to achive the second one ...here is my code find ${LOG_DIR} -name "*.bkp" -mtime +14 | xargs -i... (1 Reply)
Discussion started by: nvuradi
1 Replies

3. UNIX for Dummies Questions & Answers

Archiving big ammount of files.

Hello All. I have problem archiving files. The problem is:) I have about 10000 files in one directory, all this file aproximately the same size, i need to gzip them and write on DVD. But all this files take about 15 GB of space (already gzipped). So i need DVD Blue-Ray :p or i need to split... (3 Replies)
Discussion started by: Maxeg
3 Replies

4. Shell Programming and Scripting

Archiving the files

Hi, Suppose I have 2 files of yesterday's. And today I have received 3 files. Before processing anything I want to archieve the 2 files of yesterday's into a different folder. How can this be done? Regards, Sunitha (1 Reply)
Discussion started by: Sunitha_edi82
1 Replies

5. UNIX for Dummies Questions & Answers

Archiving and move files in the same time

Hi All, I have tried so many command but none work like i wanted. I would like archive which i assume it will move the files and archive it somewhere. for example: if i have a folder and files: /home/blah/test /home/blah/hello /home/blah/foo/bar i would like to archive folder... (6 Replies)
Discussion started by: c00kie88
6 Replies

6. Shell Programming and Scripting

Issue while archiving the files

Hi, In our current process we are reading the file, (which is placed by external vendor)from one particular folder and processing those files through ETL(informatica). We are reading these file as " ls -ltr *.txt" Once the process is finish these files are moved to archived script by "mv"... (1 Reply)
Discussion started by: Amey Joshi
1 Replies

7. UNIX for Dummies Questions & Answers

Archiving the files in a .txt file

HI , I have a file abc.txt, which has some .csv files listed. example. abc.txt 1.csv 2.csv 3.csv 4.csv 5.csv I want to move all the files listed in abc.txt to a archive directory,and zip the moved files. Can anyone help me with the script. Thanks,sai (1 Reply)
Discussion started by: saii
1 Replies

8. Shell Programming and Scripting

Archiving older files

Hello Group, I would request your help to build a shell script in order to find files older than 90 days then create the same directory structure under the second disk (/archive directory) and move the file preserving the same timestamps (ownership, etc). Also keep the log of files moved... (4 Replies)
Discussion started by: csierra
4 Replies

9. Shell Programming and Scripting

Archiving the files

hi, Am trying to acrhive a bunch of files on some ftp site and somehow managed to come out with the below logic. I'm getting "syntax error: unexpected end of file" error. Interestingly this below snipeet works fine if run for the first time but the subsequent runs fail! Anybody has any idea... (3 Replies)
Discussion started by: Amee5
3 Replies

10. Shell Programming and Scripting

Archiving files using shell script

Dear Team, I am looking for transferring files to and from the local and remote servers using SFTP commands. Currently the script is using the mget and mput commands to do the copying of the files. While I am trying to move the files from local to remote server, I would also like to archive... (21 Replies)
Discussion started by: Rads
21 Replies
AR(1)							      General Commands Manual							     AR(1)

NAME
ar - archive and library maintainer SYNOPSIS
ar key [ posname ] afile [ file ... ] DESCRIPTION
Ar maintains groups of files combined into a single archive file, afile. The main use of ar is to create and update library files for the loaders 2l(1), etc. It can be used, though, for any similar purpose. Key is one character from the set drqtpmx, optionally concatenated with one or more of vuaibclo. The files are constituents of the archive afile. The meanings of the key characters are: d Delete files from the archive file. r Replace files in the archive file, or add them if missing. Optional modifiers are u Replace only files with modified dates later than that of the archive. a Place new files after posname in the archive rather than at the end. b or i Place new files before posname in the archive. q Quick. Append files to the end of the archive without checking for duplicates. Avoids quadratic behavior in t List a table of contents of the archive. If names are given, only those files are listed. p Print the named files in the archive. m Move the named files to the end or elsewhere, specified as with o Preserve the access and modification times of files extracted with the x command. x Extract the named files. If no names are given, all files in the archive are extracted. In neither case does x alter the archive file. v Verbose. Give a file-by-file description of the making of a new archive file from the old archive and the constituent files. With p, precede each file with a name. With t, give a long listing of all information about the files, somewhat like a listing by ls(1), showing mode uid/gid size date name c Create. Normally ar will create a new archive when afile does not exist, and give a warning. Option c discards any old contents and suppresses the warning. l Local. Normally ar places its temporary files in the directory /tmp. This option causes them to be placed in the local directory. When a d, r, or m key is specified and all members of the archive are valid object files for the same architecture, ar inserts a table of contents, required by the loaders, at the front of the library. The table of contents is rebuilt whenever the archive is modified, except when the q key is specified or when the table of contents is explicitly moved or deleted. EXAMPLE
ar cr lib.a *.o Replace the contents of library with the object files in the current directory. FILES
/tmp/v* temporaries SOURCE
/sys/src/cmd/ar.c SEE ALSO
2l(1), ar(6) BUGS
If the same file is mentioned twice in an argument list, it may be put in the archive twice. This command predates Plan 9 and makes some invalid assumptions, for instance that user id's are numeric. AR(1)
All times are GMT -4. The time now is 12:23 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy