Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

7
  • See also: askubuntu.com/questions/320458/… & askubuntu.com/questions/545655/… & askubuntu.com/questions/40992/… Commented Aug 31, 2022 at 17:52
  • 1
    this, excludes="--exclude '$3'", puts literal quotes in the value of excludes, they'll stay literal as the shell doesn't parse the results of expansions for shell syntax (it would be a horrible safety issue, e.g. it'd never be possible to deal with strings like ain't so in a variable). Even if it did work, it'd fail for values that themselves contain single quotes. The subsequent $excludes will then wordsplit on whitespace, breaking any excluded paths that contain whitespace. Use an array instead since you're running Bash, which supports them. Commented Aug 31, 2022 at 20:17
  • 1
    Also (you probably know this), there shouldn't be any spaces around the = in excludes = "--exclude '/tmp'". Also the function keyword is unnecessary and non-standard, just run_backup() { ... would do to define a function Commented Aug 31, 2022 at 20:18
  • See But what if …? Commented Sep 4, 2022 at 0:53
  • 1
    Please learn how to debug.  You should have been able to track your problem down to the excludes="--exclude '$3'" line; then you could have spared us the 30-line code block, and you would have been that much closer to asking a straightforward question — and, ideally, finding a solution yourself.  And your “EDIT 2” is terrible.  You use four arguments, totaling 64 characters, and three of them are equivalent (strings of letters and slashes), and the fourth one has two special features (space and quote).  Simplify!  You present a 500+ character output and make no attempt to analyze it.  Etc… Commented Sep 4, 2022 at 0:53