Server Fault is a question and answer site for system and network administrators. 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

So I'm looking at this question: How do you backup your websites?

I was creating a script to be used with cron, and then I realized I would have to somehow input the password in the script. What is a good method to do this?

Also, is it better to make a cron job on the server I am backing up and then send the file to another server or have the cron job on the other server access the server that needs to be backed up and run the tar then grab the file?

share|improve this question
up vote 6 down vote accepted
  1. Don't roll your own backup solution.
    Seriously. Don't. You'll mess it up. There are plenty of great backup systems for Unix, and plenty of free ones, and plenty that are both.
    -Bacula (Free and good)
    -TarSnap (cheap and good)

  2. If you HAVE to do this, do it with passwordless SSH keys, and use forced commands to secure the target accounts. See the SSH man pages (ssh ; sshd - specifically re: authorized_keys) for more details.
    Implementation of the script (tar locally, rsync, etc.) would depend on your environment and needs -- do what makes sense.

share|improve this answer
+1 for keypairs and not storing passwords. – MDMarra Nov 15 '11 at 19:52
Curious, and want to understand why is it such a bad idea for making my own back up solution. There are the obvious answers, but I wanted your insight. – Doug Nov 15 '11 at 22:21
@Doug - Backups are hard - Lots of potential for disaster. Special-purpose backup software generally minimizes those risks. It is perfectly possible for you to write an excellent backup system, but why reinvent the wheel & risk screwing up a business-critical item? When a good solution already exists writing your own variation is generally a Bad Idea :) – voretaq7 Nov 16 '11 at 14:41
rsnapshot is relatively easy to manage, and rsync (on which it's based) is awesome both in preserving file attributes and in being efficient. Another +1 for ssh keyspairs – jon Dec 16 '11 at 19:19
rsnapshot is pretty cool software. I'm a little old-fashioned about my backups in that I like software that's going to treat it like a bunch of tapes and show me a tape rotation schedule, but there are many modern options with low suck quotients. – voretaq7 Dec 16 '11 at 19:30

What part of the backup do you think requires a password? If you're talking about shipping the tarball to another server via ssh, then you should look at making an RSA key pair. It will allow a secure passwordless connection from one machine to another. You shouldn't be storing passwords in plaintext in any script.

share|improve this answer
+1 for keypairs and not storing passwords. – voretaq7 Nov 15 '11 at 19:52

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.