0

i would like to import a dumped local database into a remote "azure database for mysql server" using cronjob.

in terminal it works fine with this command:

mysql -u[USER] -p[PASSWORD] -h[REMOTE-HOST] --ssl-mode=REQUIRED --ssl-ca=sslCert/BaltimoreCyberTrustRoot.crt.pem remotedb < localdb.sql

it also works, if i put that command in a shell script and call it manually.

why doesn't it work within /etc/crontab?

### import db into azure mysql server ###
*/3 * * * * itsme  /home/itsme/backup/app/dumps/import_db_into_remote.sh

the same happens if i'm trying to dump a database from remote to local via cron. it does not work.

double-beep
  • 5,031
  • 17
  • 33
  • 41
emil
  • 31
  • 1
  • 7
  • 1
    Is your cron user account allowed to do a backup and/or restore – RiggsFolly Mar 29 '21 at 15:18
  • Do you have #!/bin/bash at the top of the script? – Raman Sailopal Mar 29 '21 at 15:25
  • This may seem basic, but maybe it needs executable perms: `chmod +x /home/itsme/backup/app/dumps/import_db_into_remote.sh` – Xinthral Mar 29 '21 at 15:45
  • @RiggsFolly yes. it's the same user as in the crontab. user: itsme – emil Mar 29 '21 at 15:59
  • @RamanSailopal yes – emil Mar 29 '21 at 16:01
  • @Xinthral not even chmod 777 works. – emil Mar 29 '21 at 16:02
  • issue resolved. – emil Mar 31 '21 at 07:36
  • Welcome to Stack Overflow! I'm glad you found a solution to your problem. However, an actual answer/solution should **not** be edited into your question. In general, you should [edit] the question to *clarify* it, but not to include an answer within it. You should create your own answer with the code/solution you used to solve your problem, and then accept it (the system may require a 48-hour delay before doing so). When you've solved the problem yourself, [answering your own question is encouraged](/help/self-answer). – double-beep Mar 31 '21 at 08:09

1 Answers1

0

issue resolved. cron needs the complete path to the certificate file

mysql -u[USER] -p[PASSWORD] -h[REMOTE-HOST] --ssl-mode=REQUIRED --ssl-ca=/home/itsme/backup/app/sslCert/BaltimoreCyberTrustRoot.crt.pem remotedb < localdb.sql

emil
  • 31
  • 1
  • 7