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?
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)
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.
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.