Archiving files using shell script


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Archiving files using shell script
# 8  
Old 06-18-2015
Hi Robin,

Thanks for the tips and the suggestions.

Please find answers to your questions as below:
  1. Reasons for not recommending tar : I have suggested them this functionality but they are not recommending it.
  2. To answer your other questions: There is an already existing script performing the functionality of copying files from local to remote and vice-versa. I am just including the zip command to do archival of files to local system. So I don't think it is recommended that I change the complete script.
  3. Regarding input file 'FILE_CONFIG': It contains the details of source and target - host server, port, path and filemask (in this case it is *.csv).

Please suggest me a suitable way to do the archival with the existing functionality and also a way to log the information.

Last edited by rbatte1; 06-18-2015 at 09:13 AM.. Reason: Defined formatted numbered list rather than text number list
# 9  
Old 06-18-2015
In that case, I would suggest simply moving the zip command outside the sftp but keep it within the function. Perhaps:-
Code:
:
:
echo bye >> ${TMP_SCRIPT}

sftp -oPort=..................

zip -m ................

rm ${TMP_SFTP_SCRPT}
:
:



Robin
# 10  
Old 06-18-2015
I tried using zip outside sftp and inside function, but it is not working.
# 11  
Old 06-18-2015
Can you elaborate? Are there any error messages for example, or does the function end before you get to the zip?



Robin
# 12  
Old 06-18-2015
I am doing the testing as follows:

I am creating a Source folder(testSRC) with few csv files and a destination folder (testTRGT), both in same server. I am putting in my shell script in another server along with the configuration details of source and target hosts. When I run the shell script, it should put in the csv files from testSRC folder into the testTRGT folder. But now with this change,script is running without errors but it is not putting in the files into the testTRGT folder.

I hope it is clear. Let me know in case further information is required.
# 13  
Old 06-18-2015
Can you capture the output from the sftp rather than sending it to /dev/null so you can look at that perhaps?

Also, with the zip outside the sftp but within the function, are there any errors?



Robin
# 14  
Old 06-18-2015
Could you please guide me as to how to capture output from SFTP?

There are no errors thrown after using zip outside the sftp function
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. 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

2. 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

3. Shell Programming and Scripting

Shell script for log archiving

I have an nfs mount /logfile/project mounted on several of my application server machines. I have 5 jvms running on each machine and I have several machines. the jvms logs are created and rotated every day so it will look like /jvm1/logs/server.log.2010-10-27 /jvm2/logs/server.log.2010-10-27... (3 Replies)
Discussion started by: gubbu
3 Replies

4. 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

5. 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

6. Shell Programming and Scripting

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... (1 Reply)
Discussion started by: vsmeruga
1 Replies

7. 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

8. 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

9. 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

10. 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
Login or Register to Ask a Question