Transferring Files via ssh (bash)


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Transferring Files via ssh (bash)
# 1  
Old 11-20-2011
Transferring remote files via ssh,find,cpio locally

I am trying to transfer my website using ssh(hostbasedauthentication) using:
Code:
sudo ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "find /var/www/vhosts/mywebsite.com -depth | grep -f include| cpio -oavc| gzip" > $backup_dir/fullwwwsite$date.cpio.gz

My issue that I am having is that cpio is not on the webserver and I dont have the permission to install it. So I assumed that I can just use cpio locally to do my dirty work.

Code:
sudo ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "find /var/www/vhosts/mywebsite.com -depth | grep -f include" |cpio -oavc |gzip > $backup_dir/fullwwwsite$date.cpio.gz

I can see that the find stuff is not getting piped to my cpio locally and I get no such file errors:

Code:
cpio: /var/www/vhosts/mywebsite.com/httpdocs/data/customer/log/kwesthuba.log: Cannot stat: No such file or directory
cpio: /var/www/vhosts/mywebsite/httpdocs/data/customer/log/chaz.key: Cannot stat: No such file or directory
cpio: /var/www/vhosts/mywebsite/httpdocs/data/customer/log/mob786.key: Cannot stat: No such file or directory

What am I missing??

Last edited by metallica1973; 11-20-2011 at 10:08 PM..
# 2  
Old 11-20-2011
Maybe cpio is not in the default path. which OS for your remote server? You need use full path for it.

Code:
/usr/bin/cpio

Second, if no cpio, can you use tar command?

Code:
"tar cvf - `find /var/www/vhosts/mywebsite.com -type f -depth -name "*include*" `| gzip" > $backup_dir/fullwwwsite$date.tar.gz

# 3  
Old 11-20-2011
thanks for the reply,

cpio is present and I used the path and without. Tar is fine but I have all of my historical backups in cpio.gz format so I wanted to keep everything universal. There has to be some trick that I am not seeing.

Last edited by metallica1973; 11-25-2011 at 11:21 AM..
# 4  
Old 11-21-2011
Usually, "file not found" simply means "file not found". Perhaps there's some disagreement between that server and you on paths?

Code:
/var/www/vhosts/mywebsite.com/httpdocs/data/customer/log/kwesthuba.log

# 5  
Old 11-25-2011
So now I installed cpio on the webserver and using the include file works:

Code:
sudo ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "find /var/www/vhosts/mywebsite.com -depth | grep -f include| cpio -oavc| gzip" > $backup_dir/fullwwwsite$date.cpio.gz

but oddly when used with the exclude file which I have test locally and it doesnt work:

Code:
sudo ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "find /var/www/vhosts/mywebsite.com -depth | grep -f include |grep -v -f exclude"| cpio -oavc| gzip > $backup_dir/fullwwwsite$date.cpio.gz

I also tried which didnt work:

Code:
sudo ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "find /var/www/vhosts/mywebsite.com -depth" | grep -f include |grep -v -f exclude| cpio -oavc| gzip > $backup_dir/fullwwwsite$date.cpio.gz

it still complains:

Code:
cpio: /var/www/vhosts/mywebsite.com/httpdocs/data/customer/log/kwesthuba.log: Cannot stat: No such file or directory
cpio: /var/www/vhosts/mywebsite/httpdocs/data/customer/log/chaz.key: Cannot stat: No such file or directory
cpio: /var/www/vhosts/mywebsite/httpdocs/data/customer/log/mob786.key: Cannot stat: No such file or directory

So its appears to be "cpio -oavc" which does not want to receive output via the webserver or locally. ???????
# 6  
Old 11-29-2011
Oh, you want cpio to run on the remote side? That's good to know.

Code:
sudo ssh -o "PasswordAuthentication no" -o "HostbasedAuthentication yes" -l testuser 192.168.3.1 "find /var/www/vhosts/mywebsite.com -depth" '|' grep -f include '|' grep -v -f exclude'|' cpio -oavc| gzip > $backup_dir/fullwwwsite$date.cpio.gz

Of course, your exclude file will need to be on the remote side then.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Transferring files to directories

I have a large number of files with file names of the format iv.epoz.hhe.d.2018.028.000000.sac iv.epoz.hhn.d.2018.028.000000.sac iv.epoz.hhz.d.2018.028.000000.sac iv.epoz.hhe.d.2018.029.000000.sac iv.epoz.hhn.d.2018.029.000000.sac iv.epoz.hhz.d.2018.029.000000.sac... (4 Replies)
Discussion started by: kristinu
4 Replies

2. AIX

Rcp error while transferring files

i am trying to use a rsh script that uses the rcp command to copy files from server to server but it always produce the following error: HOSTNAME: protocol failure due to unexpected closure from server end Error: failed to copy /test to HOST2 system Error: failed to execute command on remote... (5 Replies)
Discussion started by: Portabello
5 Replies

3. Shell Programming and Scripting

Script for transferring files

Hi Guys, I have to transfer a few files in my system . The commands to be used are as follows . Will it be possible to send the output of the following in the form of a mail . cd /export/home/teja ls -lrt Quote.java* mv Quote.java Quote.java.20121023 cp /tmp/Quote.java . ls -lrt... (2 Replies)
Discussion started by: Ravi_Teja
2 Replies

4. UNIX for Dummies Questions & Answers

Transferring files from one linux server into another

Hello , I want to transfer files from one linux server into another , I got it working using SCP command , but I have to type in password for each and every file . All the remote severs have the same password , so is there a way that I can transfer all these files by typing my password only once ? (5 Replies)
Discussion started by: RaviTej
5 Replies

5. UNIX for Dummies Questions & Answers

Mget issue: not transferring more than 2 files

I am trying to transfer about 3000 files from a window platfrom to my linux server. the scrip is pretty simple ftp to the source server (windows) cd to source directory lcd to destination directory mget *.jpg what I get in the log file is: mget 07421001.jpg? 200 PORT command successful.... (4 Replies)
Discussion started by: Doveman
4 Replies

6. Emergency UNIX and Linux Support

rsync transferring multiple files issue

Hi, I want to specify multiple remote directories but want to transfer them in a single command with one connection with remote server. This avoids entering passwords repeatedly and is also efficient. e.g. rsync -vrt --size-only --delete user@host:/home/user1/dir1... (9 Replies)
Discussion started by: sardare
9 Replies

7. AIX

Transferring files via RS232 cable

Current setup: Some old AIX standalone machine (F series) My WinXP laptop Null modem cable from laptop to AIX machine (console port). On Hypterminal on WinXP I can connect to the AIX machine (serial connection), but when I try to transfer file, it will just sit there. I'm guessing the... (3 Replies)
Discussion started by: apra143
3 Replies

8. AIX

Transferring files between Windows and AIX

How do I transfer Plain Text and/or BMP image files between my WindowsXP PC and my AIX 4.1 PowerPC? I have no network or USB options, just a Floppy disk drive and a CD drive on each machine. Is it possible at all? Any help would be gratefully received:) (7 Replies)
Discussion started by: Pennant Man
7 Replies

9. UNIX for Dummies Questions & Answers

Transferring hidden files with scp

Is there a way to scp hidden files only ( with regex ) without specifying the name of the hidden files ? Many thanks in advance ! :) (13 Replies)
Discussion started by: matrixmadhan
13 Replies

10. UNIX for Dummies Questions & Answers

transferring files to and from remote computer

Hi all, i first have to ssh into my university account and then through there another ssh into my office computer, from my home computer. I have been trying to transfer files to and from with no such luck. How do i send a file from home to my office computer. Do I have to send it to my... (6 Replies)
Discussion started by: yogi1
6 Replies
Login or Register to Ask a Question