LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 10-23-2009, 02:30 PM   #1
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Rep: Reputation: 49
rsync two directories, slashes at ends of paths or not


I tried searching this on the web and see it different all over. My source folder is on the server I'm running rsync from. The folder is /data/pictures which has many subfolders. On my 1.2.3.4 server, I want to recreate pictures and all its subfolders inside of 1.2.3.4's /backups/pics-backup folder. When do I need to put a slash at the end of the folder paths and when don't I?

I think what I want to do is below, but searching on the web for when to put the trailing slash on the path has confused me as to what is right.


rsync -r -a -z -p -e ssh /data/pictures user@1.2.3.4:/backups/pics-backup/
 
Old 10-23-2009, 03:16 PM   #2
PresGas
Member
 
Registered: Jul 2008
Location: Bloomington, IN
Distribution: Ubuntu/Debian
Posts: 51
Blog Entries: 5

Rep: Reputation: 18
I think the rsync man page said it best and helped me understand it:

A trailing slash on the source changes this behavior to avoid creating an additional directory level at the destination. You can think of a trailing / on a source as meaning “copy the contents of this directory”.
So, the example that they give can be explained in this way:

rsync -av /src/foo /dest
Copy the directory by name and it's contents into /dest, creating the folder foo and what it contains in /dest.
rsync -av /src/foo/ /dest/foo
Copy the contents of the directory into the folder /dest/foo. You are not necessarily copying the actual folder foo. The destination folder can be named anything and what was contained in foo will be copied to it.

If you do not want an additional directory depth in your backup (/backups/pics-backup/pictures) you would do:
rsync -r -a -z -p -e ssh /data/pictures/ user@1.2.3.4:/backups/pics-backup
If you did want that extra pictures folder inside pics-backup, you would do:
rsync -r -a -z -p -e ssh /data/pictures user@1.2.3.4:/backups/pics-backup/

Hope that explains it a bit more.
 
Old 10-23-2009, 03:22 PM   #3
rtspitz
Member
 
Registered: Jan 2005
Location: germany
Distribution: suse, opensuse, debian, others for testing
Posts: 307

Rep: Reputation: 33
Code:
rsync -av /source/folder/ user@destination:/path
transfers only the _contents_ of '/source/folder/'

Code:
rsync -av /source/folder user@destination:/path
transfers the complete '/source/folder/' (recreates 'folder' with contents)
 
Old 10-23-2009, 03:25 PM   #4
anon091
Senior Member
 
Registered: Jun 2009
Posts: 1,795

Original Poster
Rep: Reputation: 49
Yeah, I do want the extra pictures folder, just in case I'd ever have to copy it back, I can just move that pictures folder in its entirety. Thanks guys!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I use rsync to remove source directories? tdnnash25 Linux - Server 2 10-10-2009 11:24 AM
Rsync Command Skips Directories? carlosinfl Linux - General 1 12-10-2008 11:28 AM
Mounting Partitions and Associating Paths/Directories to Them fc6_user Linux - General 8 05-16-2007 12:06 PM
Symbolic Links, directories, and relative paths (../). Can it be done? jimwillsher Linux - Newbie 1 03-11-2005 05:27 PM
recursively listing directories full paths kubicon Linux - Newbie 2 02-22-2004 03:55 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:21 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration