LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 09-01-2010, 05:42 AM   #1
Mortuus
LQ Newbie
 
Registered: Mar 2010
Location: Madrid, Spain
Distribution: Debian Testing
Posts: 21

Rep: Reputation: 0
Rsync issue with files with spaces.


Hi!

I am trying to write a script for my daily incremental backups with rsync, but I am having some trouble with files which have spaces in their name.

I am executing the following command:
Code:
# rsync -ravuz $(find "/home/mortuus/Documentos/" -mtime -7 -type f) /media/Multimedia/Backup/Debian/home_incre_$(date +%Y-%m-%d)
Files without spaces are copied successfully, but if the file has spaces, it returns the following without being copied:
Code:
rsync: link_stat "/home/mortuus/Documentos/Curriculum" failed: No such file or directory (2)
rsync: link_stat "/root/Vitae_ES.doc" failed: No such file or directory (2)
rsync: link_stat "/home/mortuus/Documentos/testing" failed: No such file or directory (2)
rsync: link_stat "/root/spaces" failed: No such file or directory (2)
The name of the two files are: "Curriculum Vitae_ES.doc" and "testing spaces" respectively. I do not get a method for escaping spaces with this command.

Any ideas?

Thanks in advance.
 
Old 09-01-2010, 05:47 AM   #2
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
I know wrapping things in quotes works, so maybe this will work;

Code:
# rsync -ravuz "$(find "/home/mortuus/Documentos/" -mtime -7 -type f)" /media/Multimedia/Backup/Debian/home_incre_$(date +%Y-%m-%d)
 
Old 09-01-2010, 05:58 AM   #3
Mortuus
LQ Newbie
 
Registered: Mar 2010
Location: Madrid, Spain
Distribution: Debian Testing
Posts: 21

Original Poster
Rep: Reputation: 0
Thanks for replying so fast.

I wrapped the first argument with quotes, and now I get the following error:

Code:
root@normandy:~# rsync -ravuz "$(find "/home/mortuus/Documentos/" -mtime -7 -type f)" /media/Multimedia/Backup/Debian/home_incre_$(date +%Y-%m-%d)
sending incremental file list
rsync: change_dir "/home/mortuus/Documentos/Curriculum-Vitae_EN.doc\#012/home/mortuus/Documentos/.~lock.ATHEROS_INSTRUCCIONES.docx#\#012/home/mortuus/Documentos/scripts/full_semanal.sh\#012/home/mortuus/Documentos/Curriculum Vitae_ES.doc\#012/home/mortuus/Documentos/testing spaces\#012/home/mortuus/Documentos/.~lock.wpa.odt#\#012/home/mortuus/Documentos/para-hacer-copia\#012/home/mortuus/Documentos/instrucciones+solicitud+admision.pdf\#012/home/mortuus/Documentos/IT-security-resume-sample.pdf\#012/home/mortuus/Documentos/estudio-sobre-tribus-urbanas.doc\#012/home/mortuus/Documentos/Resume.doc\#012/home/mortuus/Documentos" failed: No such file or directory (2)

sent 12 bytes  received 12 bytes  48.00 bytes/sec
total size is 0  speedup is 0.00
rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1060) [sender=3.0.7]
It seems that mixes all files in one.
 
Old 09-01-2010, 09:42 AM   #4
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
try this then (maybe in a script);

Code:
DATETIME=`date +%Y-%m-%d`
for file_name in $(find /home/mortuus/Documentos/ -mtime -7 -type f)
do
rsync -ravuz "${file_name}" /media/Multimedia/Backup/Debian/home_incre_${DATETIME}
done
 
Old 09-01-2010, 09:54 AM   #5
grail
LQ Guru
 
Registered: Sep 2009
Location: Perth
Distribution: Manjaro
Posts: 9,496

Rep: Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867Reputation: 2867
Untested, but if not a great deal of files I am assuming you could use exec option??
Code:
find /home/mortuus/Documentos/ -mtime -7 -type f -exec rsync -ravuz "{}" /media/Multimedia/Backup/Debian/home_incre_$(date +%Y-%m-%d) \;
 
1 members found this post helpful.
Old 09-01-2010, 10:27 AM   #6
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
Quote:
Originally Posted by grail View Post
Untested, but if not a great deal of files I am assuming you could use exec option??
Code:
find /home/mortuus/Documentos/ -mtime -7 -type f -exec rsync -ravuz "{}" /media/Multimedia/Backup/Debian/home_incre_$(date +%Y-%m-%d) \;
@grail
Oh, that should totally work! That's way better than my idea!!
/posi-rep bump

@Mortuus
Hey, give grail's suggestion a shot!
 
Old 09-01-2010, 11:46 AM   #7
Mortuus
LQ Newbie
 
Registered: Mar 2010
Location: Madrid, Spain
Distribution: Debian Testing
Posts: 21

Original Poster
Rep: Reputation: 0
Thanks to both of you

I tried Grail suggestion and it worked perfectly! Thanks! This was getting me mad hehe

I didn't know that find could exec commands, but it is a bit hard for understanding, I will search on google and on books why do you put "{}"

Thanks again. I mark this as solved.
 
Old 09-01-2010, 12:24 PM   #8
xeleema
Member
 
Registered: Aug 2005
Location: D.i.t.h.o, Texas
Distribution: Slackware 13.x, rhel3/5, Solaris 8-10(sparc), HP-UX 11.x (pa-risc)
Posts: 987
Blog Entries: 4

Rep: Reputation: 252Reputation: 252Reputation: 252
Quote:
Originally Posted by Mortuus View Post
Thanks to both of you

I tried Grail suggestion and it worked perfectly! Thanks! This was getting me mad hehe

I didn't know that find could exec commands, but it is a bit hard for understanding, I will search on google and on books why do you put "{}"

Thanks again. I mark this as solved.
The curley brackets "{}" is where find puts the pattern it finds.

Basically, if you ran the find without the -exec, the brackets {}, and the terminator \;, then find will give you a list of directories.

with -exec, the list of directories is stuffed inside {}, one by one. We need double-quotes around the {} because the file names have spaces.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
rsync can not rsync files with include filter... xiutuo Linux - Server 2 07-23-2010 02:10 AM
Could I run rsync to download files from a server without rsync daemon? Richard.Yang Linux - Software 1 09-18-2009 04:08 AM
rsync --files-from issue (v2.6.9) qwertywin Linux - Software 1 08-06-2008 02:06 PM
performance issue: rsync sends existing files microtim Linux - Networking 1 12-02-2004 02:27 AM
using rsync - one of the folders in path has spaces??? jgruss Linux - Networking 10 07-07-2004 07:27 PM


All times are GMT -5. The time now is 08:48 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration