How to preserve time stamp while copying a directory from Server B to Server A?


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to preserve time stamp while copying a directory from Server B to Server A?
# 1  
Old 09-23-2015
How to preserve time stamp while copying a directory from Server B to Server A?

Experts,

Please help me out here.

How to preserve time stamp while copying a directory from Server B to Server A
# 2  
Old 09-23-2015
Use the tar command:

Code:
# ServerA:
cd mydirectory
tar -cvf /tmp/my.tar .
scp /tmp/my.tar ServerB::/tmp/my.tar

#  ServerB:
mkdir /path/to/newdirectory
cd /path/to/newdirectory
tar xf /tmp/my.tar

# 3  
Old 09-23-2015
man scp:
Quote:
-p Preserves modification times, access times, and modes from the original file.
# 4  
Old 09-23-2015
What about rsync?

Code:
cd /home/myuser/mydata
rsync -av * username@otherserver:/home/myuser/mydata

If you already have public/private key authentication set up you won't need to type a password.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Copying multiple files and appending time stamp before file extension

Hi, I have multiple files that read: Asa.txt Bad.txt Gnu.txt And I want to rename them using awk to Asa_ddmmyytt.txt and so on ... If there is a single command or more efficient executable please share! Thanks! (4 Replies)
Discussion started by: Jesshelle David
4 Replies

2. Shell Programming and Scripting

Copying the files to Windows server from UNIX server

Hi Team, I had a requirement to write a shell script which automatically transfer the files from unix server to windows server. I can able to unix to unix using Scp command. I am not sure how to do unix to windows. I am very new on this concept. Could you please help me or guide in... (4 Replies)
Discussion started by: gvkumar25
4 Replies

3. Shell Programming and Scripting

Copying files from one server to another server?

Hi all, In Server1, one directory contains files now. In this directory, based on some operations, daily some files will generate and store regularly. Now i want to copy the files to Server2 through SFTP/FTP command on daily based on the previous day present data(i.e based on the latest file... (1 Reply)
Discussion started by: venkat6134
1 Replies

4. HP-UX

How to rename file in FP server with server time stamp?

Hello All, I am new user in this forum. Facing problem when trying to download file using Perl ::NET:FTP module. I need to rename the remote server file with latest timestamp of that ftp server. Can somebody help me if this is possible? Many thanks, (5 Replies)
Discussion started by: krsnadasa
5 Replies

5. AIX

Copying crontab for a user from one server to other server.

Could you please let me know, if the crontab for a user (eg test)in /var/spool/cron/crontabs directory can be copied from one server to other server. Both the servers are on AIX 5.3 and the target servers has the test user and all the executable files listed in the crontab for the test user on the... (1 Reply)
Discussion started by: saikiran_1984
1 Replies

6. UNIX for Advanced & Expert Users

How to copy a file from remote server and preserve timestamp

Hi How to copy a file from remote server and preserve timestamp. Please not, i have to pass username and password to connect to the remote server in the shell script. Can this be achieved with simple ftp ? are there any options in ftp ? Thanks (4 Replies)
Discussion started by: skumar75
4 Replies

7. UNIX for Dummies Questions & Answers

script copying the directory (or file) from server to my pc

Hello, I'm trying to create the shell script that: copy (or transfer) the directory from the unix server to my external hard drive (or hard drive) I've been serching this kind of thread here, but no luck so far. anyone can help me? Thank you. (2 Replies)
Discussion started by: myjwjw
2 Replies

8. Shell Programming and Scripting

copying files from one server to another server

Hi, I want to transfer files from one linux server to another linux server using shell script using sftp. But I dont won't that while connecting one server to another server it will ask for password , it should be part of script. I wont to know how password should be included in the... (4 Replies)
Discussion started by: manoj.solaris
4 Replies

9. Shell Programming and Scripting

how to pass time stamp of a file from one server to another......

We have a requirement wherein we have two servers namely A and B. Now we have to find out all the files in server B from a given location which have a timestamp greater than a file in server A. Subsequently we need to concatenate the contents of all these files and replace the same with the file... (3 Replies)
Discussion started by: jasonb
3 Replies

10. UNIX for Dummies Questions & Answers

copying directories from NT server to Unix server (solaris 5.8)

I need to copy around 30 directories (each directory include one or more text file(s)) from NT server to Unix server at one go. For doing this what are the privillages i should have in both NT and Unix server. Please let me know which command i can use in shell prompt. TIA. (4 Replies)
Discussion started by: jhmr7
4 Replies
Login or Register to Ask a Question