33 Comments
- mdxp, on 10/12/2007, -2/+13As I said in my post also... Feel free to share if you are using other solution...
"Linux on their desktop" - where did you came with this idea? anyway... "5 users" ? I am sure that you have some secret statistics of the usage of Linux... ;-)
Probably you are just a windows user that doesn't believe that there is something else besides windows... Even so, I don't see your problem since I have posted this in the proper category (linux/unix) - lcarsdeveloper, on 10/12/2007, -2/+7Been using this for 2 years. That's why I dugg it 74 days ago:
http://digg.com/linux_unix/Mysql_Database_Backup_Script
I'm getting a little tired of people creating a dumb blog talking about something they have nothing to do with, then posting it on here to get traffic. I have an idea of things I might write about on my blog:
-How to install Firefox
-Ubuntu Linux (with screenshots!)
-A useful tool to administrate MySQL databases (it's called 'phpMyAdmin'!)
-The link to the latest version of Winamp (with a 2 page description)
All I have to do is talk about it, and I'm sure out of the thousands of people who visit digg, SOME of them won't have seen it before, and they'll dig it. Of course, many people who have heard of it will still click the link.
OK I'm done ranting. Digg is starting to feel like a newspaper company that publishes the same headlines every week. Perhaps they could add some kind of extra fields for posting? For example, 'Product/Software Name', in this case it would be 'Automysqlbackup'. Then you could select if it's a news item (eg Firefox 1.5.X released), or just some kind of introduction post (like this one). Then the matching process would work a bit better, saying "someone has already told us about this product".
Does digg.com have a suggestion box? - Dreamless, on 10/12/2007, -0/+4http://www.mysql.com/products/tools/administrator/
- trib4lmaniac, on 10/12/2007, -3/+7You can use mysqldump in Windows too you know. And you can use a batch file and a scheduler to automate the process.
Still no dig because this is uber-basic stuff. - toveling, on 10/12/2007, -0/+3You can do this on a windows server automatically a batch file that calls mysqldump. I even use WinRAR's command line utility to compress and add parity data to the backup.
- Uruviel, on 10/12/2007, -1/+4*cough* cron job *cough*
- OmegaNine, on 10/12/2007, -1/+4 digg, lots of poeple run linux on thier servers, lots and lots...and SQL is server software. I need to bitch at my ISP to get some kind of solution, mySQLadmin is getting old.
Thanks for the post - rv8ch, on 10/12/2007, -0/+3I don't mean to disparage this script in any way, but over 600 lines to get to a single command line? Seems to be rather complex. My *entire* web site backup script is a whopping 11 lines, and it backs up the mysql databases and all the normal files and slaps it into a tgz.
Anyway, don't listen to me. I had an employee try to get me to do a public blog site in 1995 and I didn't get it. It's just HTML, why do we need something special? They already have web space. They add a tag and a date - new entry. Duh. - riczho, on 10/12/2007, -0/+3OmegaNine: You generally don't need root to have cronjobs (only shell access)
If you don't even have shell access, you can always make a password-protected script on the server and call/curl it with cron at home.
Additionally, a cronjob would call something like this script, not replace it. (This is mentioned in the blog post)
Still, this is complete overkill, and it's really a joke to have a SF project for this single 309 (without comments) line shell script. - Guspaz, on 10/12/2007, -0/+2My solution:
1) Cronjob to run mysqldump (Does not require root)
2) rsync to remote server
Why rsync? Well, because first of all, it can compress data as it sends it accross. Second, it can either replace existing files (keep them up to date), or backup files before updating them (keep historical archive of backups).
The trick with rsync is that it only sends the DIFFERENCES between files over the network. If only 10% of your database is different from the last backup, rsync will only send 10% of the file needed to update it. - krux, on 10/12/2007, -0/+21. Apache/PHP/Mysql dominates the web server market.
2. You can run all of the above just as easily on windows as you can linux. Though I would say Digg has a higher percentage of Linux users than your average web site, and thus it is relavant for digg even if this were a windows only.
3. Posting comments about windows users in the "linux/unix" category of digg, shows you to be an unobservant idiot.
4. Here is the backup script I wrote, that digg server folks out there may appreciate:
#!/bin/sh
# backup script
dbuser="backupuser"
dbpasswd="password"
cd /data/backups/mysql
# drop binlogs
/usr/local/mysql/bin/mysql
--user=$dbuser --password=$dbpasswd
--exec='reset master'
DATETIME=`date +%Y%m%d%H%M%S`
echo backingup mysql databases:
echo
for dbname in `ls -l /usr/local/mysql/var/ | grep -e ^d | awk '{print $9}'`
do
echo $dbname
/usr/local/mysql/bin/mysqldump
--user=$dbuser --password=$dbpasswd
$dbname > /data/backups/mysql/$dbname-$DATETIME.sql
chmod 640 /data/backups/mysql/$dbname-$DATETIME.sql
if [ $dbname = "madarab" ] ; then
chgrp madarab /data/backups/mysql/$dbname-$DATETIME.sql
fi
done
echo
# compress old files
sqldays=1
sqlsecs=`expr $sqldays * 24 * 60 * 60`
for file in `ls -1 /data/backups/mysql/*.sql`
do
timethen=`echo $file |
awk '{ str = substr($1, match($1, "-[0-9]+." ) + 1, 14)
year = substr(str,1,4)
month = substr(str,5,2)
day = substr(str,7,2)
hour = substr(str,9,2)
minute = substr(str,11,2)
second = substr(str,13,2)
printf "%s-%s-%s %s:%s:%sn", year, month, day, hour, minute, second
}'`
timethen=`date --date="$timethen" +%s`
timenow=`date +%s`
if [ `expr $timethen + $sqlsecs - $timenow` -lt 0 ] ; then
echo compressing old file "$file"
gzip $file
fi
done
# Remove old files
sqldays=7
sqlsecs=`expr $sqldays * 24 * 60 * 60`
for file in `ls -1 /data/backups/mysql/*`
do
timethen=`echo $file |
awk '{ str = substr($1, match($1, "-[0-9]+." ) + 1, 14)
year = substr(str,1,4)
month = substr(str,5,2)
day = substr(str,7,2)
hour = substr(str,9,2)
minute = substr(str,11,2)
second = substr(str,13,2)
printf "%s-%s-%s %s:%s:%sn", year, month, day, hour, minute, second
}'`
timethen=`date --date="$timethen" +%s`
timenow=`date +%s`
if [ `expr $timethen + $sqlsecs - $timenow` -lt 0 ] ; then
echo removing old file "$file"
rm $file
fi
done - OmegaNine, on 10/12/2007, -3/+5Not many people have root lvl access to thier sites, i dont even have SSH :-(
- dbr_onix, on 10/12/2007, -1/+2"Good, now the 5 users that use Linux on their desktop can back up their mySQL databases. No batch no digg."
Err, 1, most people wouldn't use mysql on a desktop, it would be on a server. 2, a lot of servers use linux. 3, most servers that would use mysql would use linux (Since both are open-source, Windows based server are more likely to use Microsofts Acess or something)
- Ben - en3r0, on 10/12/2007, -0/+1I just send copies of my database to a gmail account, with cron and all of course.
- dharm, on 10/12/2007, -0/+1like you couldnt just run the mysqldump command in a cronjob to do it automatically...
- cybe, on 10/12/2007, -0/+1Here's another one I recommend:
"Staggered import of large and very large MySQL Dumps (like phpMyAdmin 2.x Dumps) even through the web-servers with hard runtime limit and those in safe mode. The script executes only a small part of the huge dump and restarts itself. The next session starts where the last was stopped."
http://www.ozerov.de/bigdump.php - mdxp, on 10/12/2007, -0/+1And by the way... about "self promo?"
You can see in an older post from my blog that I am submitting my articles to digg, only because I believe that it is a great way to see what other peoples think about what I wrote... Is it something wrong with that? Can you point out on the digg rules that I should not do that? From what I have seen many peoples are submitting their stories to digg... But if I am wrong, please be so kind to show me what rule I am breaking. - boelder, on 10/12/2007, -0/+1Shesh - you folks are hard to please.
I dugg this, and yeah... there might be another (easy) way of doing it (I have a mysqldump nightly for my dozen or so databases), but it's still nice to share the knowledge...
-b - far2smart, on 10/12/2007, -1/+2You could try this to get a command line if you are not given SSH or telnet access.
http://mgeisler.net/php-shell/ - cybe, on 10/12/2007, -0/+1Oh and: http://www.mysqldumper.de/en/index.php is nice too
- yahooer, on 10/12/2007, -1/+1c'mon man this is lame.. everyone can backup its mysql database just by adding a mysqldump based shell script to their cron list.
- liverpoolfc, on 10/12/2007, -6/+6More spam from ducea.com
http://digg.com/users/mdxp/submitted - self promo? - drewjoh, on 10/12/2007, -1/+1Does MySQL Administrator work using SSH? Seems like I had a problem with that, and had to use NaviCat.
- makepeace, on 10/12/2007, -0/+0We started out with a simple script like this.
1 - Every 6 hours we dumped the sql to disk using rotating names so that we always had the last 4 backups.
2 - Every 24 hours we copied the last backup to a different server, with rotating names so that we had the last 7 days backups.
This worked fine but loaded the server down as sqldump is rather expensive and the backup files unnecessarily big (our database is running at 3 Gb).
We changed it over to use the mysql-hotcopy command (binary copy of table files) which is faster and uses less space. Even so it seemed inneficient to copy so much data around every 6 hours.
Now we are experimenting with using Subversion to backup the hot copy generated table files off site - the advantage is that only the things that have changed get backup up (some tables are basically lookups and never change anyway). This means that we can restore the database to its state at any day in history - which is occasionally useful if say an ex member decides to sue based on things that happened months ago and which have since been deleted.
Not only that - we can now pull down the latest db state from the svn server for development work and it only fetches the diffs since we last downloaded it, not the whole 2Gb file (we have extremely low bandwidth out here in Indonesia).
This concept is still in testing but I am quite excited about it. - mdxp, on 10/12/2007, -0/+0You might want to check on what spam means...
http://www.answers.com/spam&r=67
you can also try splog (spam blog)... then come back and let me know what part of my blog made you say that it is spam. - lcarsdeveloper, on 10/12/2007, -0/+0I have no problem with people writing about things on blogs, my problem is when they write things that aren't anything new specifically for the purpose of getting digg traffic.
Write whatever you want on your blog, but I still don't see the point of submitting it to digg. It would be better to link directly to the website of the product you're talking about, but then you wouldn't get any traffic out of it for yourself, and therefore less google clicks. - inactive, on 10/12/2007, -0/+0Because using mysqldump is SO hard...
I use pg_dumpall anyway, because mysql sucks... - sholdowa, on 10/12/2007, -0/+0There's a bit of a false sense of security to be got from this script. As you're dumping a moving target ( volatile data in the database ), what attempt are you making to get a proper snapshot ( --lock-all-tables/--single-transaction )? Also, how about making your dataset more useful if ever needed for example ( eg --extended-insert )?
A bit of background reading to improve the quality of the data set would make this a far better script. - auger282, on 10/12/2007, -1/+0Is't that what the maintenance schedule's are for? (M$ SQL)
Gee.. I guess they kinda assumed people would want to backup such things.. so they put it in with the program - mdxp, on 10/12/2007, -1/+0lcarsdeveloper, I have checked the article you are referring from debianhelp.co.uk. Indeed that is a well written article in my opinion, on the same subject... But what are you saying? Other peoples should not write about something that is already on the Internet? I thought that this is the idea of a blog (or at least so I see it), that I can write whatever i want... And if you don't like it... I am sorry to hear that, but still I believe that I can write in my own space about whatever I like... And from the feedback I got so far, many peoples found it useful, so this was not quite useless.
If this would have been a copy/paste from another source then I would have understood your point... But so, I don't get it.. - aryu, on 10/12/2007, -10/+1he's just silly, that's all.
- Kamino, on 10/12/2007, -19/+2I know it sounds like trolling but considering the mainstream runs Windows I don't consider it digg-worthy. (as backing up on the local server has no use.. say when a hard disk crashes your backups are gone too)
>> Probably you are just a windows user that doesn't believe that there is something else besides windows
I do, and the other thing I see is something made by coders without any user insights. They will never have the power (read: money) to address the gaming industry for instance. Linux users need to face they are working on an OS that has no future for client purposes. All Linux devs can do is "inspire" their GUIs on Windows and Mac OS to hope users will feel home, but the truth is they cannot play their Windows games or run Photoshop without hassle and third party hackery. And even with being backed up by large companies (Apple, Darwin?) the future is still questionable. I ain't no MS fan either, but they do know what end users want, and since they continue to improve that skill, the Windows snowball will only get bigger while the Linux one melts away.
Very offtopic, certainly. Feel free to mod down if you don't agree. - Kamino, on 10/12/2007, -37/+1Good, now the 5 users that use Linux on their desktop can back up their mySQL databases. No batch no digg.


What is Digg?