Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently, every day before I start work, I complete the following procedure:

  • ssh to the production server
  • gzip our daily database dump file
  • scp the gzipped dump file over to my computer
  • gunzip the dump file
  • dropdb mydatabase
  • createdb mydatabase
  • psql mydatabase < dump.sql

Is it possible (I'm sure it is) to automate this process on Mac OSX? This way it is done by the time I get to work in the morning. If so, what is the quickest and easiest way?

share|improve this question
comment from Jim: This question might be better suited for – quack quixote May 8 '10 at 2:38
up vote 1 down vote accepted

I would set this up as a couple shell scripts run by cron.

On the server, set up a job to gzip the db dump file and copies it to a known location like /home/russ/backups/latest.gz. Schedule this script to run via cron so that it finishes with at least 30 minutes to spare before the client job runs.

The client side script would do rest -- all the client side stuff.

If you want to be more mac-like, you'll run your client side script via launchd instead of cron, but cron should work fine also.

If you don't already have the skills to do this, I think this is a great project to help you learn shell scripting and cron scheduling.

share|improve this answer
i couldn't find a crontab file on the mac, i usually use cron on our servers and that would e fine. Is it as simple as creating a file called /etc/crontab or is there more to it? – Russ Bradberry May 7 '10 at 21:07
You should use the crontab command to create the crontab file... got that? Modern versions of cron prefer this method. It locks the file while it's being edited and triggers the cron daemon to reload after it's been saved. I found this link that describes itself as "a quick and simple guide to crontab usage" and that looks right: – Doug Harris May 7 '10 at 21:22

You can use Expect for the job. This program can start jobs, and send input to the process based on the output it gets.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.