- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- scp command to exclude particular directory
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 05:31 AM
тАО05-06-2010 05:31 AM
Please adivce, i have to copy all directories & files under directory to remote server but wanna exclude 1 directory.
kindly confirm the scp command option.
else i am thinking of making 1 server as nfs & mount the fs & then start copy with cp.
but cp too doesnt have exclude option .
rsync is having but --exclude doest recognize the PATTERN directory name.
can any confirm the correct command & syntax.
for exclude sigle directory....
Solved! Go to Solution.
- Tags:
- scp
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 06:03 AM
тАО05-06-2010 06:03 AM
Re: scp command to exclude particular directory
scp do not have any include exclude option and that is why rsync can be use.
> rsync is having but --exclude doest recognize the PATTERN directory name.
What patern you are trying. To exclude any directory you can use the --exclude option with rsync.
You have to the exclude option with double quote that will match the regex. Also you must put the / in the directory you want to exclude:
Ex:
# rsync -avz --exclude=sapr1/ --exclude=saparch1/ source_host:/data/ target_host:/data/
Hth,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 06:09 AM
тАО05-06-2010 06:09 AM
Re: scp command to exclude particular directory
http://lists.samba.org/archive/rsync/2002-June/002970.html
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 06:20 AM
тАО05-06-2010 06:20 AM
Re: scp command to exclude particular directory
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-06-2010 11:26 PM
тАО05-06-2010 11:26 PM
Re: scp command to exclude particular directory
Or use pax(1) or gnu tar and exclude that directory when you create the tarfile (or when you extract.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2010 04:00 AM
тАО05-07-2010 04:00 AM
Re: scp command to exclude particular directory
I have boxA
I want to copy over boxA:/opt/stuff to boxB:/mydir/stuff
I want to exclude subdirectory /opt/stuff/racerX
I want to exclude any file with the word BLUE in them.
on boxA
cd /opt
find ./stuff -print > /tmp/stufflist.txt
cd /tmp
edit text file ./stufflist.txt
remove subdirectory ./stuff/racerX
remove any lines with BLUE in them
save the file
Log into box B
cd to mydir
Just sit there.
Go back to box A.
--Now here comes the magic part--
cat ./stufflist.txt | cpio -odumc | /usr/bin/ssh \
-2 \
mylogin@boxB \
"cd /mydir/.
/usr/bin/cpio -idumc"
BUT! be careful. I'd start with just 2 or 3 files and directories.
SMALL ones.
Make sure it works.
Then move to larger things.
Now other guys... This has worked fine for me. But perhaps there is something wrong? Let me know.
Oh...
The find command will not follow links unless you tell it to. And I would NOT tell it to.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2010 12:01 PM
тАО05-07-2010 12:01 PM
Re: scp command to exclude particular directory
scp -r $(ls | -e /directory_not_to_copy/d) remote:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2010 12:14 PM
тАО05-07-2010 12:14 PM
Re: scp command to exclude particular directory
scp -r $(ls | sed /directory_not_to_copy/d) remote:
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2010 12:24 PM
тАО05-07-2010 12:24 PM
Solution# scp -r $(ls | grep -v -e dir_to_exclude1 -e dir_to_exclude2 ) trg_host:/trg_dir/
Hth,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2010 12:27 PM
тАО05-07-2010 12:27 PM
Re: scp command to exclude particular directory
find /stuff > filelist.txt
vi filelist.txt
scp -r $( cat filelist.txt ) trg_host:/trg_dir/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-07-2010 03:37 PM
тАО05-07-2010 03:37 PM
Re: scp command to exclude particular directory
edit text file ./stufflist.txt
remove subdirectory ./stuff/racerX
remove any lines with BLUE in them
You can also use find's ! -name/-path and -name and -prune to eliminate them.
>cat ./stufflist.txt | cpio -odumc | ...
>scp -r $( cat filelist.txt ) ...
I'd leave out the evil cats:
cpio -odumc < stufflist.txt | ...
scp -r $( < filelist.txt ) ...
>be careful. I'd start with just 2 or 3 files and directories. Make sure it works.
Right.
- Tags:
- evil cat
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2010 03:51 AM
тАО05-08-2010 03:51 AM
Re: scp command to exclude particular directory
Raj.D
can i use below syntax..
# scp -pr * $(ls | grep -v -e dir_to_exclude1 -e dir_to_exclude2 ) trg_host:/trg_dir/
scp all of them except above 2 directories.
Please confirm...
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2010 04:32 AM
тАО05-08-2010 04:32 AM
Re: scp command to exclude particular directory
Probably. Will it do what you want? Seems
unlikely.
> scp -pr * $(ls | [...]
Why "*" _and_ all the ls+grep stuff?
> Please confirm...
What happens when you _try_ it? (What is my
opinion worth? Ask the computer.)
> >be careful. I'd start with just 2 or 3
> files and directories. Make sure it works.
>
> Right.
I'm with them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2010 05:20 AM
тАО05-08-2010 05:20 AM
Re: scp command to exclude particular directory
why the * before: as Steven said , thats correct, and test before actual run.
# scp -pr * $(ls | grep -v -e dir_to_exclude1 -e dir_to_exclude2 ) trg_host:/trg_dir #incorrect!#
This is not right When you specify * before the 'filtered listing' , it will generate the 'complete' list from your current directory.
Remove the * and you can use it.
Lets see the syntax:
SYNTAX: scp [options] [user@]host1:]file1 [user@]host2:]file2
or to make it simple it is just similar to copy command:
# scp [options]
Here: $(ls | grep -v -e dir_to_exclude1 -e dir_to_exclude2 ) will work as source file listing:
You can check by executing :
# echo $(ls | grep -v -e dir_to_exclude1 -e dir_to_exclude2)
- replace the exclude1 and 2 with your actual directory name. You will see the list. And all those scp will copy. Remeber this will not copy the hidden files under current directory. You can do a small scp test from a test directory and then run the actual copy you are intending to copy.
Hth,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2010 06:25 AM
тАО05-08-2010 06:25 AM
Re: scp command to exclude particular directory
Another way you can achieve the same thing:
And if you have large number of file/dir to exclude:
1. Generate the scp command list.
2. Edit with vi & Remove the lines not needed.
3. save the file, execute the file .
Here is is example:
-------------------
1. Generate the command list:
# ls -l | grep -v total |awk '{print "scp -pr " $9 " adms-desktop:/home/2/ ;printf " NR ":RC='\$\?' "}' > command_list
# ls -l | grep -v total |awk '{print "scp -pr " $9 " trg_host:/trg_dir/ ;printf " NR ":RC='\$\?' "}'
scp -pr 1 trg_host:/trg_dir/ ;printf 1:RC=$?
scp -pr abc trg_host:/trg_dir/ ;printf 2:RC=$?
scp -pr abcd trg_host:/trg_dir/ ;printf 3:RC=$?
scp -pr abcd1 trg_host:/trg_dir/ ;printf 4:RC=$?
scp -pr abcd23 trg_host:/trg_dir/ ;printf 5:RC=$?
scp -pr abcdEE trg_host:/trg_dir/ ;printf 6:RC=$?
....
2. Edit the list: & remove un-wanted:
# vi command_list
- /search_file_dir --> and delete the line
- save.
3. Excute:
# chmod +x command_list
# ./command_list
- Limitations: Any file/directory name in the current directory contains white space, it will not copy.
- Hidden files on current directory will not copy.
- The output will be on its way as the copy progress with Line_number:Result Code (RC=0). 0 means successful.
Hth,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2010 10:57 PM
тАО05-08-2010 10:57 PM
Re: scp command to exclude particular directory
Your solution has worked. i have tried & successfull transferred.
Full marks... ;)
Dear Steven
i have asked ..
But thanks for your time & consideration.
regards.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2010 11:04 PM
тАО05-08-2010 11:04 PM
Re: scp command to exclude particular directory
I too have tried & successful.
thanks to all of them for there time & consideration.
regards
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО05-08-2010 11:08 PM
тАО05-08-2010 11:08 PM