A colleague is attempting to back up a mysql database on a Windows machine from a linux machine on a schedule. The linux and windows machines use different versions of mysql, so we can't run mysqldump on the linux machine and connect it to the Windows machine, so instead, he is running mysqldump on the windows machine over SSH and piping the output to a file. He wrote a script, tested it, then scheduled it with cron (without testing that) and, of course, it failed -- when run through cron, the SSH of mysqldump produces no output, so the backup file is 0 bytes. The same script run without cron produces a mysql backup.
That's when I got involved.
I've fiddled with it in several different ways. I've piped the env to disk, added SSH verbosity, wondered if it had anything to do with TTY, so tried with -t
, -tt
and -T
, but I've still got no idea why it fails. I can see by adding -v
to SSH that the connection is being made, authentication is succeeding, command is being sent. The only real difference is that when I schedule the script via cron, the mysqldump output is missing.
I can post sanitized output of the SSH debug logs if anyone thinks they will help. Can get the Windows, CentOS and MySQL versions if they're relevant. Happy to try suggestions.
Ultimately, we can probably redirect the mysqldump output onto the Windows disk instead and then copy the file, so there's probably an alternate path to success, but I'm puzzled by what's happening and I'd prefer to understand. ;)