Move Directory & Contents Between Two Machines


 
Thread Tools Search this Thread
# 1  
Move Directory & Contents Between Two Machines

Hi All,

I have a large amount of files that I need to copy from one server to another server using SFTP. Can comeone please help me with the command I would use here?

Here is what I am thinking, but being new at this I know this is probably wrong:

Login to the destination host using putty (Lets say this is server 10.0.0.1)

Code:
 
Navigate to destination directory
Type: sftp root@10.0.0.2 :/directory_to_copy
Type:  mget *.pdf (This will copy all the pdf files from the directory to the new host)
Type: mget *.class (This will then copy all the class files from the directory and move them to the new host)

Is this correct?

Moderator's Comments:
Mod Comment edit by bakunin: i don't know how you got in all these FONT-tags, but: please don't use them. It enhances readability not one bit but sometimes makes posts quite hard to read. Thank you.


---------- Post updated at 11:20 AM ---------- Previous update was at 10:50 AM ----------

Quote:
Originally Posted by SalientAnimal
Moderator's Comments:
Mod Comment edit by bakunin: i don't know how you got in all these FONT-tags, but: please don't use them. It enhances readability not one bit but sometimes makes posts quite hard to read. Thank you.
Apologies for this, I copied and pasted my question from an outlook mail. I didn't add any additional tags except for the CODE tag.

Last edited by bakunin; 11-08-2012 at 05:02 AM..
# 2  
sftp does not perform a recursive get ( it does not read down through a directory tree)
Consider making a tar archive on system A, sftp the tar file to system B and then unarchive the tar file. There are other more elegant means using ssh, but this appears to be a one-off deal.
Example:
Code:
cd mydirectory
tar cvf /tmp/myfiles.tar .
# now you have a tar file, move it to another host:
sftp remotehost
usrname password
put /tmp/myfiles.tar /tmp/myfiles.tar

on the remote host
Code:
mkdir mydirectory
cd mydirectory
tar xf /tmp/myfiles.tar

 

Previous Thread | Next Thread
Thread Tools Search this Thread
Search this Thread:
Advanced Search

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Solaris 9 Home Directory, Two Machines Sharing a NAS

Good Morning, I have 2 Solaris 9 machines sharing a NAS, and need to have users to be able to log in from the 2nd machine and get to all of their files on the NAS that were created on the 1st machine. So far its working ok, but when users log in to the second machine, their user IDs show... (20 Replies)
Discussion started by: Stellaman1977
20 Replies

2. UNIX for Beginners Questions & Answers

Best way to move the contents of a folder to another one

what is the best way to move the contents of a folder to another one without deleting the structure of the first one. the contents could include subfolder too. both folder, the source-folder and the target-folder are on the same host. any idea is appreciated . (7 Replies)
Discussion started by: andy2000
7 Replies

3. Shell Programming and Scripting

Shell script cannot create directory and move the file to that directory

I have a script, which is checking if file exists and move it to another directory if then mkdir -p ${LOCL_FILES_DIR}/cool_${Today}/monthly mv report_manual_alloc_rpt_A_I_ASSIGNMENT.${Today}*.csv ${LOCL_FILES_DIR}/cool_${Today}/monthly ... (9 Replies)
Discussion started by: digioleg54
9 Replies

4. Shell Programming and Scripting

List files with date, create directory, move to the created directory

Hi all, i have a folder, with tons of files containing as following, on /my/folder/jobs/ some_name_2016-01-17-22-38-58_some name_0_0.zip.done some_name_2016-01-17-22-40-30_some name_0_0.zip.done some_name_2016-01-17-22-48-50_some name_0_0.zip.done and these can be lots of similar files,... (6 Replies)
Discussion started by: charli1
6 Replies

5. Shell Programming and Scripting

If contents of A are in B then move the common contents to C

Hallo Team, I have 2 .csv files file A has 47600 lines and file B has 67000 lines FILEA SD0o9rb01-1d320ddbcc8d220f572739ebed5f58d1-v300g00 SD8bt0101-a0810bfe0e3396060126ec51b30dac0a-v300g00 SD05sce01-cb056af347ed4651f29eb3c3e9addbd6-v300g00... (3 Replies)
Discussion started by: kekanap
3 Replies

6. Shell Programming and Scripting

Move parent folder if contents match a parameter

Hi all, Hoping someone can help. I'm looking to be able to search a particular folder path for folders that contain certain files / formats and then move the parent folder. eg. /foo/bar/folder1/file.exe /foo/bar/folder2/file.exe and then move the folder1/2 tp another folder. So if... (1 Reply)
Discussion started by: springs2
1 Replies

7. Programming

Script for creating a directory & move the .tif files in it.

Hi Team, I have thousands of TIF files which are converted from PDF. Below is a sample of it. LH9406_BLANCARAMOS_2012041812103210320001.tif LH9406_BLANCARAMOS_2012041812103210320002.tif LH9406_BLANCARAMOS_2012041812103210320003.tif LH9411_ANGENIAHUTCHINSON_2012041812102510250001.tif... (9 Replies)
Discussion started by: paragnehete
9 Replies

8. UNIX for Dummies Questions & Answers

ssh autologin issue when both machines are having same ~home directory

Hi, I have two machines. M1 and M2 and having a generic id catadm, these two machines having common mount of /u/catadm directory. with this setup, ssh autologin is failing for me and asking me to enter password when i try autologin using this generc id from M1 to M2 catadm-M1$ ssh... (3 Replies)
Discussion started by: rbalaj16
3 Replies

9. Shell Programming and Scripting

move contents from one file to another based on line number or content

I want a script that will move everything beyond a certain line number or beyond a certain content word into another file. For example, if file A has this: first line second line third line forth line fifth line sixth line I want to run a script that will move everything beyond the third... (4 Replies)
Discussion started by: robp2175
4 Replies

10. UNIX for Dummies Questions & Answers

Move contents of a directory into one file for e-mail distribution ...

Hello, Here is what I am trying to accomplish. I am going to have one directory in which there will be files of varying types (Excel, Word, PPT, and possible others), and I need to be able to be bundle however many files there are in there together in to one file to be used as an e-mail... (3 Replies)
Discussion started by: rip73
3 Replies

Featured Tech Videos