View Full Version : automatic backup
AliensX 02-25-2002, 09:19 PM Hello,
Does anyone know of a script that would zip mysql databases and send it to my local machine daily? Does this exist?
Thx!
agiledesigns 02-25-2002, 09:26 PM I am quite sure some sort of cron job script exists for this. Since you need the script being in tha background, you will not be able to use PHP or ASP scripts because they cannot execute indefinitely. I have not done this before, but if you look up writing cron job scripts, I am sure you will be able to do what you want to.
sorry that I could not be of more help
cheers. :beer:
allan 02-25-2002, 10:22 PM http://reoback.penguinsoup.org/
Reobackup automates the zip and FTP process. If FTP does not work for you, it should be trivial to modify the scripts to e-mail you the files instead, if you prefer.
Abu Mami 02-26-2002, 03:54 AM I needed this too and wrote a simple script that does just what you need:
http://web.abumami.com/scripts/amrssbosm.html
This works on dedicated servers and any hosting that give you access to shell functions from within PHP. In spite of the stupid name, it works great. I set up several CRON jobs using this script to backup a number of my databases on a daily basis. I send the backup files to a web based email account for "offsite" storage.
I also wrote another simple script for backing up the scripts that power my web sites:
http://web.abumami.com/scripts/hindsite.html
This works in a similar manner as the script above.
Using these two scripts I'm able to easily, automatically, and cheaply keep my sites and their data backed up. (No, I'm not selling anything, these scripts are available for free.)
If you have trouble accessing the above links directly, try the URL for the site itself:
http://web.abumami.com
I hope this helps.
CapitalWeb 02-26-2002, 04:00 AM Just wanted to say I use Abu Mami's script to backup a few of my databases and I have to say it works great and is very easy to setup:)
serve-you 02-26-2002, 04:09 AM I wrote a really simple shell script that runs mysqldump, tarballz it, and scp's it to a backup machine. I posted it in the plesk forum if you are interested: http://forum.plesk.com/showthread.php?s=&threadid=1946&highlight=mysql+backup
-Dan
Ahmad 02-26-2002, 06:55 AM Now that is a really simple one:
#! /bin/sh
FILENAME=`date "+%d-%m-%Y_%H:%M:%S.sql"`
mysqldump -uuser -ppass database > $FILENAME
gzip $FILENAME
note that it doesn't send the file, you have to add your command at the end to send it they way you want.
priyadi 02-26-2002, 08:18 AM Originally posted by robx
Hello,
Does anyone know of a script that would zip mysql databases and send it to my local machine daily? Does this exist?
Thx!
It is probably more practical to have your local machine download it daily. Your local machine might has dynamic IP, or is behind firewall.
Use something like this in cron (assuming your local machine is running Linux/UNIX):
ssh user@server "mysqldump -u dbuser -pdbpass dbname | gzip" > localbackup.sql.gz
Abu Mami 02-26-2002, 09:22 AM Just thought I'd mention one point about using scripts such as these... They consume bandwidth. If you've got excess bandwidth, or if your backup files aren't too big, then making backups via these scripts is fine. I've been doing backups this way for a few months, but I've got plenty of bandwidth to play with right now. As my site builds traffic, I guess it'll get to the point where I'll have to avail myself of the backup service my server provider offers. In the meantime, I've got free backup.
Abu Mami 02-26-2002, 09:27 AM Originally posted by Ahmad
Now that is a really simple one:
<cut>
Ahmad,
Nice script. I'm not much of a Linux expert, and I know even less about shell scripts. I know PHP so I chose to write my scripts in PHP. But I'm going to file your cute little script away for use on a rainy day when I feel reckless and want to try my hand at shell scripts. Thanks.
AliensX 02-26-2002, 09:44 AM Hey... Thank you guys!! Wow..... I didn't expect so many answers.... ! I really thank you all :-)
priyadi, nope... I know this would be the easiest way, I guess... but my local machine is not running linux... it is running xp :-(
priyadi 02-26-2002, 10:26 AM Originally posted by robx
Hey... Thank you guys!! Wow..... I didn't expect so many answers.... ! I really thank you all :-)
priyadi, nope... I know this would be the easiest way, I guess... but my local machine is not running linux... it is running xp :-(
Then, what about emailing you the backup file?
mysqldump -udbuser -pdbpass dbname | gzip > database.sql.gz
metasend -b -f database.sql.gz -F from@address -s "database backup" -t email@address
AliensX 02-26-2002, 10:57 AM Well.. the thing is... I have one of those backup services that checks my local computer for any changed files everyday so I would need to have the back up sent to any directory in my local hard drive rather than having it emailed to me.
priyadi 02-26-2002, 11:31 AM Originally posted by robx
Well.. the thing is... I have one of those backup services that checks my local computer for any changed files everyday so I would need to have the back up sent to any directory in my local hard drive rather than having it emailed to me.
Okay... does your local computer have a fixed IP address? If it does, the easiest way is to run an FTP server on your local computer, and have the server upload the backup file every day.
AliensX 02-26-2002, 02:18 PM Yes, It does have a fixed IP address. Now... no security problems with this solutions? What do you think? And... what ftp server would you recommend?
priyadi 02-26-2002, 06:07 PM Originally posted by robx
Yes, It does have a fixed IP address. Now... no security problems with this solutions? What do you think? And... what ftp server would you recommend?
I'm not familiar with Windows server. But to automate the process from your server you can use ncftpput.
There are always security problem with FTP, since your password is transmitted in clear text. But that's the most practical way if you are still using Windows on your local side.
AliensX 02-26-2002, 06:12 PM okay.. thank you. I really appreciate your answers!!
Tazzman 05-30-2002, 09:32 AM I'd like to use one of these scripts to backup multiple databases of multiple sites to a second harddrive in the same machine. Think it would be much of a problem to edit the scripts to do this? Also, could these scripts be easily modified to do weekly backups of entire sites to the same second harddrive? I don't see the need to backup sites on a daily basis, but weekly would be nice for the people on my server. Use of the script would be strictly non-commercial.
I see reoback would work fine for backing up the sites, but I couldn't see anything about backing up databases on the reoback site...
Domenico 05-30-2002, 11:30 AM Ehm, it's not exactly safe to send your database through email don't you think?
Have you ever thought of this?
Tazzman 05-30-2002, 02:09 PM Also don't know any email providers that offer enough room to store multiple and/or large sites, that's why I just want to send everything to a second harddrive. That way if the main drive fails or has to be formatted, everything would still be sitting safe on drive 2. It would also be handy for repairing individual sites with a minimum loss of data should anything go wrong with a site anywhere.
To me a second harddrive seems to be the best solution other than having a server just for backups, which would be very costly...
bacid 05-30-2002, 03:32 PM transferring files using rsync with ssh keys would be the most secure way...
|