0

I'm working in a location with a physical server, and the company I am working for is in a different location, and has a cloud server with a different address.

Database backups work using automysqlbackup script in the cloud server also. But the database backups that I want to pull from the cloud server is quite huge and cannot be exported to my local server using phpMyAdmin.

So can I use the scp command in the crontab to pull the backed up database daily into my local server? , i.e :

* * * * * scp -r [email]root@cloudservername:/backups/databasename.sql.gz[/email]

Thanks.

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Aigini
0

Not sure if the cron environment or the crontab itself will support the use of scp in that shell the way you want to use it. I'd suggest pulling the scp command out into some script file and then running the script, after you explicitly set any required or assumed environment variables. Something like:

* * * * * /path/to/script.sh

where /path/to/script.sh is your new script and inside it, you have:

#!/bin/bash
export ENVIRONMENT_VAR=foo
#whatever else you need
scp -r root@cloudservername:/backups/databasename.sql.gz > /tmp/output.log
0

What does export ENVIRONMENT_VAR=foo do, and what do I actually add in #whatever else you need?

This topic has been dead for over six months. 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.