How to copy filename with spaces using rsync

Putting rsync script with spaces in filename in bash. Finally found answer here: http://lists.samba.org/archive/rsync/2002-January/001217.html http://lists.samba.org/archive/rsync/2002-January/001219.html On the command line, or explicitly in a script, it works fine, however when I invoke it from a script it throws errors. Key is to use the "eval" keyword, see example below. #!/bin/bash # -------------------------------- # Edit the three settings below. # -------------------------------- # # Define home location # home="/home/hutcho" # # Backup directories # backupDirs=("Projects" "Directory With Spaces" "Desktop" "Other" "Personal" "Utils") # Define backup location # Note that you also need to define the path to the backup location in /etc/fstab. More info at: http://en.wikipedia.org/wiki/Fstab # fstab (file system table) entry is as follows: # //IPADDRESS/d$/hutcho_backup /home/hutcho_backup smbfs username=yourusername,password=yourpassword,noauto 0 0 # backuphome="/home/hutcho_backup" # this must match the entry in fstab. # -------------------------------- # Nothing to edit below this line. # -------------------------------- # Map path to backup folder on dingbat echo sudo mount $backuphome sudo mount $backuphome for ix in ${!backupDirs[*]} do echo sudo rsync -rvu \"$home/${backupDirs[$ix]}/\" \"$backuphome/${backupDirs[$ix]}/\" eval sudo rsync -rvu \"$home/${backupDirs[$ix]}/\" \"$backuphome/${backupDirs[$ix]}/\" done echo "" echo "" echo "Done. Press the any key to close this window." read

Comments

Popular posts from this blog

PHP timezones explained

iPhone Internet Tethering settings