Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
01-19-2010, 12:01 PM
|
#1
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Rep:
|
Rsync half a directory to one folder, other half to another folder, based on name
Hi everybody. I have another post that this one is in relationship too, but thought it was different enough and off-topic of the original post enough that I'd make a new topic for it. Plus its a subject where I really struggle being new.
I have a huge directory that I need to move to another location with rsync. But I don't want to sync it to one folder at the destination, i want to split it into two folders. I guess ideally I'd want symbols,numbers, A through L in one folder on the destination, then M-Z in the other. since that's how i think it naturally sorts them. I just dont know how to do it to split the source into two destinations. For example, I know how to recursively rsync from say /data1/documents to /data2/documents, but don't know how to sync the first half of the folders when listed alphabetically from /data1/documents to /data2/A-L_documents then the second half to /data2/M-Z_documents. Under my /data1/documents is where all the folder names i'd want to copy are and separate based on those names, like /data1/documents/Al, /data1/documents/Zed, etc
I'm not even sure how to do a find to show me just those folders in question.
|
|
|
01-19-2010, 12:06 PM
|
#2
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Hello,
You could of course write a script to sort the files and output them to a list, next using that list as input for rsync. But in my opinion it's a lot easier to use a tool like Unison, which synchronizes directories and files in a very easy way. It comes with a lot of possibilities including filters. I think you'd be better of with that utility.
Kind regards,
Eric
|
|
|
01-19-2010, 12:08 PM
|
#3
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Original Poster
Rep:
|
I'm only able to use the command line though. Will that work through there as well?
|
|
|
01-19-2010, 12:11 PM
|
#4
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Hi,
Of course it runs from command line. I don't even know if it has a GUI interface, since I only run it on servers (no GUI at all). In my opinion it's worth looking into since the configuration is a lot easier then rsync.
Kind regards,
Eric
|
|
|
01-19-2010, 12:22 PM
|
#5
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Original Poster
Rep:
|
Thanks, I will definitely check it out, i never even heard of it before.
I'll leave the post open for a bit until i can try it, and that will also let people comment on rsync as well for future use by others perhaps.
|
|
|
01-19-2010, 12:24 PM
|
#6
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Great, I hope it can help you out. If you encounter problems installing or configuring it you can of course post them here on LQ.
Kind regards,
Eric
|
|
|
01-19-2010, 12:28 PM
|
#7
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Original Poster
Rep:
|
if it goes like everything else i've tried in Linux, I will definitely have questions! :-)
|
|
|
01-19-2010, 12:31 PM
|
#8
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Hey, who doesn't? There's nobody that has all the answers but a community like LinuxQuestions comes pretty close to offering an answer to almost any question you can think of. I know I've gotten a lot of answers from this site.
Kind regards,
Eric
|
|
|
01-19-2010, 12:33 PM
|
#9
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Original Poster
Rep:
|
Thanks Eric. I know I would have given up by now if it weren't for this site. Google doesn't even help me at this point, because I don't even know the proper terms to search for.
|
|
|
01-19-2010, 03:48 PM
|
#10
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Original Poster
Rep:
|
I dont know if I'm going to be able to install Unison on my server.
Does anyone know how I could do this via rsync?
|
|
|
01-19-2010, 04:48 PM
|
#11
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,440
|
If you look at the man page http://linux.die.net/man/1/rsync you'll see you can use the usual Unix filename wildcards eg *.c etc.
|
|
|
01-19-2010, 04:53 PM
|
#12
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Original Poster
Rep:
|
Hi Chris. I saw that it will accept wildcards, but this is where my limited knowledge fails me. I still struggle even using the find command. How do I tell it to only grab any folder who's name starts with a symbol, number, or letters A-L, to only rsync those folders to a destination. then i imagine i would run a second rsync to grab only the folders who's names start with M-Z.
Under my /data1/documents, there are a ton of folders, but i only want to grab half at a time, and breaking them up in alphabetical order seemed most logical to me, but technically i'm clueless on how to accomplish this.
|
|
|
01-19-2010, 05:11 PM
|
#13
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,440
|
There's loads of examples on that page, but something like
rsync -avz /src/bar/A* host:/data/tmp
choice of flags is up to you.
|
|
|
01-19-2010, 06:00 PM
|
#14
|
Senior Member
Registered: Jun 2009
Posts: 1,795
Original Poster
Rep:
|
since i'm using fat32, i think I need to do the following line, then repeat for each letter I want, or is there a more streamline way to do it?
rsync -t --modify-window=1 /src/bar/A* host:/data/tmp
Also, if i do it without a -r, does that mean its only going to copy the folders beneath bar and not their contents, or do i need to add in -r to get all the pictures in all those folders?
|
|
|
01-20-2010, 02:14 AM
|
#15
|
LQ Guru
Registered: May 2009
Location: Gibraltar, Gibraltar
Distribution: Fedora 20 with Awesome WM
Posts: 6,805
|
Quote:
Originally Posted by rjo98
I dont know if I'm going to be able to install Unison on my server.
|
Why would you say that? Unison is included in several repositories such as the Debian repos. So installation should be as simple as running (for Debian)
Code:
apt-get install unison
What distro are you using?
Kind regards,
Eric
|
|
|
All times are GMT -5. The time now is 11:57 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|