4

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?

2 Answers 2

6
  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.

5
  • +1 for keypairs and not storing passwords.
    – MDMarra
    Nov 15, 2011 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.
    – Strawberry
    Nov 15, 2011 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, 2011 at 14:41
  • 1
    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
    – jade
    Dec 16, 2011 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, 2011 at 19:30
3

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.

1
  • +1 for keypairs and not storing passwords.
    – voretaq7
    Nov 15, 2011 at 19:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .