Cron and auto backups


#1

With all the downtime recently, I’ve prioritized setting up automatic backups for my server.

I’m following these instructions:
http://wiki.dreamhost.com/index.php/Automatic_Backup

However, whenever I try to run the scripts, I get the error:

/bin/sh: /home/myusername/backups/mysql.sh: /bin/bash
: bad interpreter: No such file or directory

I’ve looked into other posts in here related to this, but didn’t find any concrete answers.

Please advise.


#2

try this, from putty use the “cd” command to move into your backups directory:
cd backups/
then open the script with a text editor like nano:
nano -w domain.sh

If my guess is right nano will say “converted from DOS format” towards the bottom of your screen. Press ctrl-o (both at the same time) to save the file and ctrl-x to exit. Now test the script and see if it runs.

As a side note, could you please let me know what operating system you’re using, how you saved the file on your computer, and how you uploaded it to your server (what program did you use)? A few people have had similiar problems with my little backup script and I’m trying to figure out what I can change in the instructions so that it works for people. Thanks!

–Matttail
art.googlies.net - personal website


#3

Thank you for your quick and helpful reply!

Your assumptions were correct: I performed the tasks you outlined and the scripts were able to run.

Also, DH support let me know that I could run

dos2unix domain.sh

to convert the files.

So, now the backups are working, however I get this email whenever domain.sh is run:

tar: Removing leading `/’ from member names

I found this reference to this same error:
http://lists.trustix.org/pipermail/tsl-discuss/2003-May/005835.html

How to avoid getting this error?

That thread goes on to talk about that it’s bad to backup a running MySQL db. Should the DB be locked before it’s dumped?

Lastly, how would you modify the sh scripts to send the backups to another (non-DH) server?

TIA!


#4

heh, the best way to avoid that error is to not listen to my advice. :wink:
I made a change to the wiki article recently, decided to cut the backup command down to one line, but apparently tar doesn’t like that method as well.

Change your backup scripts from this:

tar -cf /home/user/backups/archives/domain.$suffix.tar /home/user/.snapshot/nightly.0/domain.com

to this:
cd /home/user/.snapshot/nightly.0/
tar -cf /home/user/backups/archives/domian$suffix.tar domain.com/

(that’s two lines, one starting with “cd” the other with “tar”)

I do not believe that there’s any need to shut down or ‘lock’ the database before backuping up that data. I’m fairly certin that a mysql dump is designed to take backups while the DB is running.

[qupte]Lastly, how would you modify the sh scripts to send the backups to another (non-DH) server?[/quote]
Hmm, that’s a fun question. You can either have your DH server send it to your ServerB, or visa versa. It shouldn’t make any difference in speed.
I think what I’d do would be to use sftp to send the files. Basically you’d take the instructions for automatically downloading your files to a linux machine and switch them around a bit to suit your needs. You could also use “scp” to send the files. (I don’t know of any way to send the files if you don’t have sftp or ssh access)

Hope that helps. Thanks for the convert utility, I’ll add a not about that to the wiki.

–Matttail
art.googlies.net - personal website