Can someone look at this and tell me why I'm getting an empty tar?

mysqldump --opt --user=[my username] --password=[my password] | tar cvz > backup.tar.gz
echo | mutt -a backup.tar.gz -s \"Database Backup\" [my email]
rm backup.tar.gz


7 Years
Discussion Span
Last Post by ConCon

tar -c will not accept input from stdin, so your ... | tar <args> cannot succeed. Think about these options:
1: Do you really need tar format for a single file? Why?
2: Do this in two steps: First dump the data, then zip or tar zip the resulting file (see mysqldump --help, look for the -r flag ... unless you are on Windows, in which case redirecting onto a file is better)

Votes + Comments
Thanks, after you said that I realised I had mysqldump set up wrong too.

1) Good question. I don't.

2) I've looked for the command to do what I want to do, and I think that's it (minus the " | tar cvz" now, of course). I just want to make a backup of my databases and send them to myself. But when I implement the command without tar, it sends me an empty sql file?

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.