I'm using Ubuntu 15.10. I have noticed a weird problem.
When running a rsync
command embedded in a shell script (as root) with --exclude={}
options, rsync
works and excludes paths as it's supposed to when I launch it as root via
./rBackup.sh
However, when I run it as root via
sh rBackup.sh
the exclude directory options do not carry over, and it infinite loops when backing up the drive it's backing up to in /media/
. Why?
Edit - this is not a sh / bash difference - or shouldn't be. I have #!/bin/bash as the first line, so when running via "sh *.sh" it should use the bash interpreter - at least, in theory.
Script is as follows:
#!/bin/bash
StandbyMount="/media/astump/sdb2"
mount /dev/sdb2 $StandbyMount
rsync -aAXv --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found,/etc/fstab,/boot/grub/grub.cfg} --delete-before / $StandbyMount
umount $StandbyMount
rm -fr $StandbyMount
#!/bin/bash
there. If you call script withsh script.sh
it will run withsh
. – Sergiy Kolodyazhnyy Feb 09 '16 at 16:28