Unix/Linux Go Back    

Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

rsync multiple directories into single directory on remote

Shell Programming and Scripting


Thread Tools Search this Thread Display Modes
Old Unix and Linux 01-30-2011
wreckedred wreckedred is offline
Registered User
Join Date: Jan 2011
Last Activity: 3 August 2012, 3:59 PM EDT
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
rsync multiple directories into single directory on remote

I would like to find and backup all *.mp4 files from /Pictures and its sub-directories and move them to a single directory on a remote. I can find and move the files but I don't want the directory structure...just the files to be placed in a single remote directory.

To find my files I use

rsync -r -a -v -e "ssh -l user" --delete --include '*/' --include  '*.mp4' --exclude '*' /home/drew/Pictures/ remoteserver:/Users/drew/mp4

but this creates all the subdirectories

I also tried

find ~/Pictures -name "*.mp4" -exec rsync -r -a -v -e "ssh -l user" --delete {} remote:/Users/drew/mp4 \;

This works but takes forever

Any suggestions?


Last edited by Scott; 01-30-2011 at 12:18 PM.. Reason: Please use code tags
Sponsored Links
Old Unix and Linux 01-31-2011
DGPickett DGPickett is offline Forum Advisor  
Registered User
Join Date: Oct 2010
Last Activity: 1 February 2016, 3:35 PM EST
Location: Southern NJ, USA (Nord)
Posts: 4,673
Thanks: 8
Thanked 587 Times in 560 Posts
Since rsync wants to make matching directories, it might be good to give it multiple directories (a mirror), but then hard link the files to another single directory on the same device. A cron script could remove files no longer having 2 links and link new files (having only 1):

rm $( find common_dir -type f -links 1 )
ln $( find ... -type f -links 1 ) common_dir

Sponsored Links

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
rsync a single file timgolding Shell Programming and Scripting 2 10-19-2010 11:03 AM
rsync multiple remote directories one connection sardare Shell Programming and Scripting 0 03-11-2010 12:44 AM
Renaming files after their directory name in multiple sub directories robotsbite UNIX for Dummies Questions & Answers 2 07-16-2009 12:54 PM
single quote problem with rsync mr_boysito Shell Programming and Scripting 9 12-05-2008 08:49 PM
Copy single file to multiple directories kthatch UNIX for Dummies Questions & Answers 2 11-11-2007 05:10 PM

All times are GMT -4. The time now is 10:11 AM.