[Solved] Need help to copy files to another server


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers [Solved] Need help to copy files to another server
# 1  
Old 10-02-2013
Computer [Solved] Need help to copy files to another server

Hi all,

I need a shell script to compress and transfer only last modified(new) file from one linux server to another linux sever.

the files i need to backup are 2 files .txt & .log which will be created in the same folder for every 3-4hrs and this script need to run once in 24hrs.

so only newly created one .txt & .log file need to compress and transferred..
# 2  
Old 10-02-2013
As the script runs every 24 hours, this boils down to finding the files newer than a certain date/time (the date/time of the last run) and then transfer them, yes?

Create with touch (see man touch) a file with the timestamp of the last run of the script you write, then use find ... -newer <this file> to find all the files newer than this. Process this list of files in a loop and transfer them via scp (or whatever means of transfer you prefer, scp is just my suggestion).

I hope this helps.

bakunin
# 3  
Old 10-02-2013
Hi bakunin,

Thanks for your response.
Example: below are the files in the folder with modified time
Code:
A1.log 6.00am
A1.dmp 6.00am
A1.txt 6.00am
A2.log 9.00am
A2.dmp 9.00am
A2.txt 9.00am
A3.log 12.00pm
A3.dmp 12.00pm
A3.txt 12.00pm

backup script will run at 12.30pm which needs to backup only A3.log & A3.txt compress and scp.

pls give me idea to pick A3.log & A3.txtand compress. Thank You

Last edited by Scott; 10-02-2013 at 10:11 AM.. Reason: Please use code tags for code and data
# 4  
Old 10-02-2013
That does not sound logical. Why would you want to backup A3.* only if the script runs every 24 hours? Which means A1 and A2 aren't backed up yet.
Use bakunin's proposal find ... -newer timestamp ... to create a list of files to be backed up now, then immediately touch timestamp to make sure all files created after this will be backed up next time the script runs (unfortunately this can't be done in an atomic operation so there's a small chance that a file created in that split second between find and touch will be missed next time. Reversing the order raises a small chance of doubly backed up files).
# 5  
Old 10-03-2013
Thanks....
solved using
Code:
find -ctime

# 6  
Old 10-06-2013
Quote:
Originally Posted by basszzz
solved using
Code:
find -ctime

Not what i had in mind, but if it serves your purpose you're welcome....

Moderator's Comments:
Mod Comment changed thread status to "Solved"


bakunin
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copy multiple .txt files from one server to another server

:wall:Hi all, I have two servers : server A and server B Weekly wise i use to receive files to server A to one particular location say /source/location . NOTE: In this location there will be other files also present other than these weekly arrival 18 files. My task : i need a... (7 Replies)
Discussion started by: karmegam
7 Replies

2. Shell Programming and Scripting

Copy Directories with Files from One Server to Other using sftp

Hi, I have a requirement where I have to connect to another server and copy directories from one server to another Directories on the Source server look like below (YYYY-MM-DD- 1 to 23) drwxr-xr-x 2 test_user dmfmart 422 Sep 1 23:45 2014-09-01-18drwxr-xr-x 2 test_user dmfmart ... (1 Reply)
Discussion started by: arunkesi
1 Replies

3. Shell Programming and Scripting

Copy files from Linux server to Windows server

Hi All, I am generating report in a Linux server and once the report is generated the report(.txt file) needs to be automatically saved in a Windows servers. So i am looking for a script to transfer the file automatically from Linux server to Windows server? Please advise. Thanks... (3 Replies)
Discussion started by: arunmanas
3 Replies

4. Shell Programming and Scripting

Copy folder and files from unix server to linux server

We would be migrating unix solaries to Linux redhat. Basically source is unix and target is linux. i would like to copy entire file system unix/source/* to target linux/souce/* but target linux has only folder setup so what ever files copied need to be placed in the linux server with same... (8 Replies)
Discussion started by: balajikalai
8 Replies

5. UNIX for Advanced & Expert Users

Copy files from SVN Server

Hi, We have a SVN server on which the developers upload their source code which is in the form of a .ear file or a folder. We login to the SVN server using our credentials and then go to the directory in which the application is placed and then click on the download link to download the... (6 Replies)
Discussion started by: mohtashims
6 Replies

6. Shell Programming and Scripting

Copy latest files from another server

Hi, I wanted to copy monthly generated csv file(s)( of latest date) at one server to my current server. So I wrote the following script, but does not work. The script is invoked on my current server Can you please help? !/bin/ksh #. /apps/comp/ cd /apps/di/dev/import/paper ssh hpqad02... (3 Replies)
Discussion started by: Alok Ranjan
3 Replies

7. UNIX for Advanced & Expert Users

Best way to Copy Files From One server to another server

Hi , I have two servers say server A and server B. I am generating some files in server A which I have to copy to Server B,what will be the best option and why it is better than the other( as I have to copy more than 3 GB data files daily) 1.FTP - I can't use FTP bcoz it's not allowed due to... (2 Replies)
Discussion started by: wangkc
2 Replies

8. Shell Programming and Scripting

(yet another) copy files from windows to server question

Hi all, I spent the last few hours Googling for a solution without result, so here goes: I have Windows server 'source' that produces files that need to be copied to an external Linux server 'target'. I initiate this process from AIX server 'jobrunner'. An additional step is a Linux server... (2 Replies)
Discussion started by: whbos
2 Replies

9. UNIX for Dummies Questions & Answers

Copy files from remote server

Hi Friends, Could you please help me as per my requirement mentioned below ? I have to copy files from one unix server to another unix server, and the files that i need to copy from the remote server are only those which are modified/created Today from abc directory on the remote server (1 Reply)
Discussion started by: ramask
1 Replies

10. Shell Programming and Scripting

copy files from remote server (B) to target server (A)?

Hi All, what is the comand to log off the remote server? I have 2 servers A, B. I need to find all files older than 7 days on server B and copy over to server A. My logic is: login the remote server: ================= ssh hostB cd /data/test find . -mtime -7 -ls | awk '{print... (4 Replies)
Discussion started by: Beginer0705
4 Replies
Login or Register to Ask a Question