mysqldump to a tar.gz

mysqldump –opt <database> | gzip -c | ssh user@wherever ‘cat > /tmp/yourfile.sql.gz’ You can’t use tar in a pipe like this, and you don’t need it anyway, as you’re only outputting a single file. tar is only useful if you have multiple files.

Can you have more than one ~/.ssh/config file?

The ~/.ssh/config file don’t have a directive for including other files, possibly related to SSH’s check for file permissions. Suggestions around this can include a script to cat several changes together either on the system or via checkin hooks on a repository. One might also look into tools such as Puppet or Augeas. However you … Read more

Clean way to write complex multi-line string to a variable

This will put your text into your variable without needing to escape the quotes. It will also handle unbalanced quotes (apostrophes, i.e. ‘). Putting quotes around the sentinel (EOF) prevents the text from undergoing parameter expansion. The -d” causes it to read multiple lines (ignore newlines). read is a Bash built-in so it doesn’t require … Read more