I've made a very simple script to perform backups:

#!/bin/bash
# ~/backup.sh

(
    while read line
    do
        rsync -az $line rbmj@example.com:~/
    done
) < backupdirs

And backupdirs:

~/Music
~/code

Now, when I run the commands manually...

$ rsync -az ~/Music rbmj@example.com:~/
$ rsync -az ~/code rbmj@example.com:~/

Everything works as planned. However, when I use the script (which should theoretically do the exact same thing as those two commands):

$ ./backup.sh > /dev/null

I get on stderr:

rsync: change_dir "/home/rbmj/~" failed: No such file or directory (2)
rsync error: some files/attrs were not transferred (see previous
errors) (code 23) at main.c(1070) [sender=3.0.8]
rsync: change_dir "/home/rbmj/~" failed: No such file or directory (2) 
rsync error: some files/attrs were not transferred (see previous
errors) (code 23) at main.c(1070) [sender=3.0.8]

Why is it doing this? If I just run echo $line, it just outputs ~/Music and ~/code on their own lines as I would expect.

Thanks!

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.